Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 947045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:01:08+00:00 2026-05-15T23:01:08+00:00

In scala, here docs is begin and end in 3 val str = Hi,everyone

  • 0

In scala, “here docs” is begin and end in 3 "

val str = """Hi,everyone"""

But what if the string contains the """? How to output Hi,"""everyone?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T23:01:08+00:00Added an answer on May 15, 2026 at 11:01 pm

    Since unicode escaping via \u0022 in multi-line string literals won’t help you, because they would be evaluated as the very same three quotes, your only chance is to concatenate like so:

    """Hi, """+"""""""""+"""everyone"""
    

    The good thing is, that the scala compiler is smart enough to fix this and thus it will make one single string out of it when compiling.

    At least, that’s what scala -print says.

    object o {
      val s = """Hi, """+"""""""""+"""everyone"""
      val t = "Hi, \"\"\"everyone"
    }
    

    and using scala -print →

    Main$$anon$1$o.this.s = "Hi, """everyone";
    Main$$anon$1$o.this.t = "Hi, """everyone";
    

    Note however, that you can’t input it that way. The format which scala -print outputs seems to be for internal usage only.

    Still, there might be some easier, more straightforward way of doing this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a copy of the interpreter commands: scala>val myTable = Array(Array(1)) res30: Array[Array[Int]] =
scala> val input = readLine(hello %s%n, world) hello WrappedArray(world) input: String = scala> val
scala> Float.floatToI On pressing tab here, it displays Float.floatToIntBits . But, scala> Float.floatToIntBits(2f) <console>:6:
( Note : I'm using Scala 2.7.7 here, not 2.8). I'm doing something pretty
I'm new to Scala... Here's the code: def ack2(m: BigInt, n: BigInt): BigInt =
I'm having a problem with scala generics. While the first function I defined here
scala> val l = List((1,2), (2,3)) l: List[(Int, Int)] = List((1,2), (2,3)) I can
Scala includes the continuations plugin now (yay), but must be enabled by passing -P:continuations:enable
scala> val m = Map(1 -> 2) m: scala.collection.immutable.Map[Int,Int] = Map(1 -> 2) scala>
Using Scala's command line REPL: def foo(x: Int): Unit = {} def foo(x: String):

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.