Run ruby script in terminal with parameters -


How do I run this method in terminal / IRB and test different parameters?

def add (* numbers) numbers.inject (0) {| Sum, number | Zodiac + number} expiration

hence the parameter 4 & amp; 6 I would think: ruby ​​add_method.rb 4,6 or ruby ​​add_method.rb (4,6) but can not detect / detect the correct execution code When I run them to work for it, I do not get any new prompts.

Save it to a file:

def add (* numbers ) Numbers.inject (0) {| Sum, number | Zodiac + number} end result = add (* ARGV.map (& amp; to to_i)) results

then it will be ruby ​​add_method.rb 4 6 .


Comments

Popular posts from this blog

c++ - C/pp Sockets, recv()/send() works only under gdb -

GO: Serve static pages -

objective c - How to open front/back camera at the same time in iOS developing? -