Breaking News: Grepper is joining You.com. Read the official announcement!
Check it out

Syntax for Single Variable Expressions#

Sumit Rawal answered on May 23, 2023 Popularity 1/10 Helpfulness 1/10

Contents


More Related Answers


Syntax for Single Variable Expressions#

0

You can place any expression after the $. For a single variable expression, you can simply place the variable name after the $ and Scala will interpret all the characters until the last character of the variable identifier.

In our example above, the variable identifier was country. Scala interpreted the variable until the y of country and afterward, processed ! like any other character.

Let’s now try to embed a mathematical expression in a string. As a mathematical expression doesn’t have any identifiers, letting the compiler know what to interpret and what to take as a regular character is done by modifying the syntax for single variable expressions.

Syntax for Expressions with Non-Identifier Characters

The expression you want the Scala compiler to process will be placed in curly brackets. The opening curly bracket will immediately follow the $. 

Popularity 1/10 Helpfulness 1/10 Language scala
Source: Grepper
Tags: scala syntax
Link to this answer
Share Copy Link
Contributed on May 23 2023
Sumit Rawal
0 Answers  Avg Quality 2/10


X

Continue with Google

By continuing, I agree that I have read and agree to Greppers's Terms of Service and Privacy Policy.
X
Grepper Account Login Required

Oops, You will need to install Grepper and log-in to perform this action.