I'm currently doing advent of code in Scala 3 to learn a bit of this language.
For loop does weird things there. It can be used as a flat map as it can iterate over multiple iterators at once and yield a value for each combination.
What's bitten me so far multiple times is that when you iterate over a Set or a Map the result of for expression is also a Set or a Map.
But since you have access to keys during iteration then some iterations, if they return same map key or same set value, might get silently overwritten by others.
I don't remember having this problem in Rust because there I had to be very intentional about iterators.
The other thing that bit me was that arithmetic on Int overflows silently, but that's apparently a Java thing, which made me wonder how is Java an enterprise language.
Otherwise Scala 3 is superb expeirience. Syntax is ultra-flexible and local extensibility of everything and access to things from the context of where your code is defined and even from the context where it's running is magical.
For loop does weird things there. It can be used as a flat map as it can iterate over multiple iterators at once and yield a value for each combination.
What's bitten me so far multiple times is that when you iterate over a Set or a Map the result of for expression is also a Set or a Map.
But since you have access to keys during iteration then some iterations, if they return same map key or same set value, might get silently overwritten by others.
I don't remember having this problem in Rust because there I had to be very intentional about iterators.
The other thing that bit me was that arithmetic on Int overflows silently, but that's apparently a Java thing, which made me wonder how is Java an enterprise language.
Otherwise Scala 3 is superb expeirience. Syntax is ultra-flexible and local extensibility of everything and access to things from the context of where your code is defined and even from the context where it's running is magical.