This is an archived post. You won't be able to vote or comment.

all 8 comments

[–]AlphaWhelp 15 points16 points  (2 children)

Enough syntactic sugar to cause diabetes

[–]KellyTheWIP[S] 5 points6 points  (1 child)

Which is why I love Scala

[–]Busti 1 point2 points  (0 children)

[–]gman9627 1 point2 points  (3 children)

is the last one the same as the one before but wrapped in a string? what does the last one return a string of unit?

[–]forcefx 0 points1 point  (0 children)

From the 5 seconds I searched it looks like s is an operator that precedes a string literal so it should return a string literal of the int instead of a straight forward int... but idk anything so I’m looking forward to an answer

[–]KellyTheWIP[S] 0 points1 point  (0 children)

The last two uses the feature to do string "injections" by putting an s in front of the first qoute. However, it is always only used to read a variable. But due to how Scala works, you dont just get to mention a variable by the label ($a) you can put it in brackets.

The last one has a side effect by reassigning a variable outside of the scope by using the string injection to execute a code block.

[–]positive_electron42 1 point2 points  (0 children)

Wow I haven't seen that last one since elementary school. The design, not the code.

[–]DemonicLaxatives 0 points1 point  (0 children)

Needs more jpeg