H
Hd Pwnz0r
Hi.
I'm learning Ruby and I want to know how to make a script have an
argument, i.e.
ruby script.rb 3 2
So far I have this:
abort "Correct syntax is ruby [script].rb [number to exponentially
multiply by] [exponent]" unless ARGV.size == 2
var = gets.chomp
var2 = gets.chomp
puts (var.to_i ** var2)
It's a simple exponential calculator.
I get this error when trying to run it with 2 arguments (2 and 3).
exponent.rb:2:in `gets': No such file or directory - 2 (Errno::ENOENT)
from exponent.rb:2:in `gets' from exponent.rb:2:in `<main>'
Attachments:
http://www.ruby-forum.com/attachment/4895/exponent.rb
I'm learning Ruby and I want to know how to make a script have an
argument, i.e.
ruby script.rb 3 2
So far I have this:
abort "Correct syntax is ruby [script].rb [number to exponentially
multiply by] [exponent]" unless ARGV.size == 2
var = gets.chomp
var2 = gets.chomp
puts (var.to_i ** var2)
It's a simple exponential calculator.
I get this error when trying to run it with 2 arguments (2 and 3).
exponent.rb:2:in `gets': No such file or directory - 2 (Errno::ENOENT)
from exponent.rb:2:in `gets' from exponent.rb:2:in `<main>'
Attachments:
http://www.ruby-forum.com/attachment/4895/exponent.rb