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

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -