Robert Klemme
7/26/2007 7:05:00 AM
2007/7/26, Guo Yangguang <gyg22@163.com>:
> hello:
> can you help me ?we all know that we can use a class'object in main
> method in java,but how can i use a class'object after designing a class
> in ruby? i only know i can make an object and use it after having a
> class,i can also use a class method in a class to get some result after
> designing a class method.But why i can do that? i do not know the
> reason? is there an only place like main method of java in which i can
> use my classes? is there a rule that can guide me to use my ruby class
> correctly?
As has been mentioned already, the body of the script file is what in
Java is your "main" method. Arguments are in ARGV, i.e. you can do
ARGV.each do |arg|
puts arg
end
You can as well read from ARGV - which is a kind of IO that combines
all file names on the command line. A simple "cat" replacement looks
like this:
ARGV.each do |line|
puts line
end
Kind regards
robert