Pedro Gordo
Pedro Gordo

Reputation: 1865

Difference between method type and value in Scala

Reading this post he speaks about "Methods Values" but right in the next paragraph he says that "A Method Type is a non-value type. That means there is no value". Isn't this contradictory? In Scala, does a method have a value or not?

I know that we can't assign a method to a variable (without turning it into a function by using _), isn't this enough to say that a method does not have a value?

Upvotes: 1

Views: 140

Answers (1)

Som Bhattacharyya
Som Bhattacharyya

Reputation: 4112

If m is a method then the method value is m_ which is actually a function. So it has a function type . A method value has a function type. A method type is just the def statement without the body. It cannot be used anywhere! This is how i look at it.

Upvotes: 2

Related Questions