Hacker News new | ask | show | jobs
by javajosh 1732 days ago
Not a scala programmer, but I searched for "scala cheatsheet" and got the answer:

https://docs.scala-lang.org/cheatsheets/

Double arrow seems to have multiple uses - for anonymous functions (like in js) and for pass-by-reference arguments (I guess scala is pass-by-value by default).

(Surprised at how Erlang-y it feels, especially WRT pattern matching)

2 comments

As noted in the parent, I read the cheat sheet. It doesn't cover the use case for => I was trying to understand.

The best (but still not exhaustive) doc is : https://stackoverflow.com/questions/7888944/what-do-all-of-s...

Sure but the issue is that when a single symbol has multiple meanings that presents an obstacle to learning the language and understanding a code base.
How do you feel about = (assignment and equality check)? Or > which can be used for markup or less than or part of a function arrow? Or {} which can be used as a block or as an object? Or : which can be used for...so many things! Even the humble . can be used to dereference or as a decimal point. My point is that if "a symbol having multiple meanings" is a problem, then basically all languages have a problem.
Obviously that's a bad idea, which is why many languages don't overload = with two purposes.

{} always means "group of related stuff"

: always means : (sic) separator between a thing and something about the thing.

Well Java isn't too bad in that regard. It uses = for assignment and == for equality.