" ".
Scala, , :
trait X {
val y: Int
}
" "!
trait MyMath[T] {
val square: (T) => T
}
object IntegerMath extends MyMath[Int] {
val square = (i: Int) => i * i
}
IntegerMath.square(2)
... " ". , , , . (, ), .
# , , . .
, .
There are many different types of programming languages: some without side effects (bloating) - and this really should be at least mentioned so as not to be automatically packed (lame Java pun) in a certain way (C / C ++, for example) of thinking , especially when it comes to theory of language design.
Happy coding.
user166390
source
share