What is meant by below scala declaration :
type MyType = Int => Boolean
Here is my understanding :
I’m declaring a new type ‘MyType’ but what is meant by the higher order function ‘Int => Boolean’
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s not so much declaring a new type as declaring a new type alias. They’re still the same type: but the alias lets your write it a little more succinctly.
Int => Booleanis the type of a function that takes one argument, an Int, and returns a Boolean.For example, a function like “greater than 5” could have type
Int => Boolean: