Friday, 15 April 2011

Creating .method in ruby -



Creating .method in ruby -

how create method takes variable object it's called upon...

for illustration in "hello".to_s, .to_s takes "hello" argument.

edit:

thank answering question!

for wondering how this, here's example:

def double self*2 end 2.double =>4

thanks again

in exemple, in to_s body can refer "hello" using self. if that's not you're asking, need describe bit improve problem.

ruby

No comments:

Post a Comment