Reputation: 8125
For example, in Ruby I can write
def initialize(price)
@Current_price = price
end
Upvotes: 8
Views: 13276
Reputation: 62835
In scala you write all init in class/trait/object body:
class Foo(price: Int) {
val currentPrice = price
}
or simply
class Foo(val currentPrice: Int) {
}
You can think of class body as of primary constructor method, as DNA said.
Upvotes: 16