boriskr ([personal profile] boriskr) wrote2017-01-23 08:28 am
Entry tags:

Trying to learn Scala

I started to read "Scala puzzlers" yesterday evening. This is not as fun as "Java puzzlers", but it was so interesting that when I looked at the time it was 3 am!

There is aсtually a puzzle (Init you, init me):

object XY {
object X {val value: Int = Y.value + 1}
object Y {val value: Int = X.value + 1}

I have to figure out, why is it XY.X.value or XY.Y.value throws StackOverflowError, while the book says it should return 2.

In "Count me now, count me later" puzzle explanation it turned out that in order to understand Scala code, I have to know what the "eta expansion" is. This thing is from lambda calculus, which I knew nothing about, but ok, I've also read about alfa conversion and beta reduction too. Who knows what I'll need in the future.