Sunday 15 May 2011

Remove Characters from the end of a String Scala -


What is the easiest way to remove the last character from the end of a string in scala?

I think there are some very useful methods in the Ruby string class like Cut I used "odononets". Ideopation in Scala, but it's collapsed. I do not want to go to the extreme premises:

  string.slice (0, string.length - 1)  

Please tell me there this normal form There is a simple method like cutting for anything.

Regarding using the drop-down, which works in 2.8: -

< Pre> "abc!". DropRight (1)

which produces "abc"


No comments:

Post a Comment