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

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -