Ruby function definition -


how define function in ruby such call f[true,1,2,3] made? tried
def f(arr) ... end
requires f([true,1,2,3]).
i'm total newb in ruby, need complete task.

i'd this:

class myclass     def [](a,b,c,d)         print "#{a} #{b} #{c} #{d}"     end end  f = myclass.new  f[true,1,2,3]   # => true 1 2 3 

Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -