ourList := { 1. 2. 3 }.
ourList collect: [:in | in + 1 ].
Here it is in Kotlin: val list = listOf(1, 2, 3)
list.map { it + 1 }
No spurious colon, dots sprinkled a bit everywhere, mysterious ":in" or pipe bar, square brackets. Just a very naked syntax.Next:
ourList select: [ :num | (num \\ 2) = 0 ] thenCollect: [:n | n + 2]
Kotlin: list.filter { it % 2 == 0}.map { it + 2 }
The next example is an ever better illustration of why Smalltalk feels so antiquated and wasteful, and is not respecting the developer's time: ourList chain
select: [ :num | (num \\ 2) = 0 ];
collect: [:n | n + 2];
collect: [:m | m + 2].
Why do I have to find names for all these closure parameters? And why use a different name every time (num, n, m).Again, Kotlin shows how to do it right:
list.filter { it % 2 == 0}.map { it + 2 }.map { it + 3 }