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

  • Home
  • SEARCH
  • 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 6107473
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:11:32+00:00 2026-05-23T14:11:32+00:00

Reading the Programming in Scala 2nd Ed and I came across this: literal identifier

  • 0

Reading the Programming in Scala 2nd Ed and I came across this:

literal identifier
“The idea is that you can put any string that’s accepted by the runtime as an identifier between backtick”

I’m not entirely sure why I would use this? The book gave a use case of accessing the static yield method in Java’s Thread class.

So since in Scala, yield is a reserve word, if I use yield with backticks,

Thread.`yield`()

it would ignore the Scala’s yield and let me access the Java’s Thread class’s method yield instead?

Thank you in advance.

  • 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-23T14:11:33+00:00Added an answer on May 23, 2026 at 2:11 pm

    Exactly. Using backticks, you can more or less give any name to a field identifier. In fact, you can even say

    val ` ` = 0
    

    which defines a variable with name (one character of whitespace).

    The literal definition of identifiers is useful in two cases. The first case is, when there is already a reserved word of the same name in Scala and you need to use a Java library which does not care about that (and of course, why should it).

    The other use case comes with case statements. The convention is that lower case names refer to match variables, whereas upper case names refer to identifiers from the outer scope. So,

    val A = "a"
    val b = "b"
    "a" match {
      case b => println("b")
      case A => println("A")
    }
    

    prints "b" (if the compiler were dumb enough not to fail with saying case A were unreachable). If you want to refer to the originally defined val b, you need to use backticks as a marker.

    "a" match {
      case `b` => println("b")
      case A => println("A")
    }
    

    Which prints "A".

    Add There is a more advanced use case in this recent question method with angle brackets (<>) where the backticks were needed to get the compiler to digesting the code for a setter method (which in itself uses some ‘magic’ syntax).

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

Sidebar

Related Questions

From reading parts of the Programming in Scala book, I realize that Scala can
I'm reading through Programming in Scala. It says: You can redefine the behavior of
While reading Programming Ruby , I ran across this code snippet: while gets num1,
While reading Essentials of Programming Languages I came across top down and bottom up
I started reading Programming Pearls today and while doing it's exercise I came across
I'm reading a book on scala programming (the Programming in Scala), and I've got
I'm reading Programming Perl , and I found this code snippet: sub new {
I'm reading The C Programming Language (2nd ed.) and near the beginning, it has
I'm reading about functional programming and I've noticed that Pattern Matching is mentioned in
Possible Duplicate: Which IDE for Scala 2.8? I'm learning Scala by reading 'Programming in

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.