On Sun, Feb 14, 2010 at 9:58 AM, Raul J. [email protected]
str.strip => new_str
I’m afraid I have no idea how to call a method like toutf8. Â I don’t
know what’s up with # sign, either. Â Anyone willing to explain this to a
novice like me?
The hash notation is used to indicate an instance method. In this
case, #toutf8 is a method that returns a string. The “str.strip =>
new_str” form is showing the same thing, but by way of example. It’s
just an inconsistency in the docs.
We use a hash to signify instance methods because you call class
methods with a .:
the first is referring to the ‘new’ method on class String, the second
is referring to the instance method ‘split’ on strings. So, to call a
method that is documented as Class#method, you would create an
instance of that class and then call it in the normal way.
In this case, you’d do:
“some string goes here”.toutf8