I want to do something like this:
scala> "Hello world"(this.length -1)
res30: Char = d
This obviously doesn’t work as I can’t reference “Hello world” without first storing it as a val.
Is there some way to achieve this ?
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.
If you just want the last character of the string, you can just do:
For a general problem, you might want to use the forward pipe operator, as shown below:
You can either define forward pipe operator as shown below, or use the one available in Scalaz.