I am trying to simplify a square call.
Is this the best way?
(1 to 10).map(x => x*x)
Declare this once somewhere:
def sqr(x: Int) = x * x
And use it like this afterwards:
(1 to 10).map(sqr)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With