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 -

android - IBM Worklight 6.1 [Application Error] There was a network error (file:///android_asset/www/index.html) -