This is useful when I don’t want to use implicits but would like to have a function to convert from (e.g.) Int to MyClass.
This is useful when I don’t want to use implicits but would like to
Share
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.
In Scala, an
objectis used to define static methods. What you are describing sounds like you want this:So that you can do either of these:
I would call this a “factory method”.