Starting with Ruby
by Vijay Kiran
Ruby language has been the talk of the town for the past one year or so. Its a scripting language like Perl, Python and TCL. I’ve programmed with perl and also had entry level experience with Python. So I started off learning Ruby recently. Coming from the Java world, where even for simple operation we have to write all the nonsense code to get to to the actual stuff, Ruby surprises me with its simplicity. Just for example consider the following code fragment in Java:
public class test{ public static void main(String[] args){ String[] fruits = { "apple" , "mango" , "banana" }; for(String s : fruits){ System.out.println(s); } } }
Which can be done in ruby with :
%w{ apple banana mango}.each { |name| puts "#{name} \n" }
I’m not arguing here that you can reduce all your java code to lesser lines using Ruby. It’s just one example how Ruby handles the stuff elegantly. I’ll find out more about ruby before talking more about it!
