| I'm kind of kidding, but Ruby lets you do things more elegantly than you can in Perl, and with less verbosity (hence the Java comment). It's really a syntax issue that I'm talking about, but it matters a lot for readability and language usability. Perl: my $x = 'Apple Carrot Banana'; # sort them into an array my @y = sort split(' ', $x); # do we have more than 2 elements? (just a random test) if (scalar(@y) > 2) { print "we've got ", scalar(@y), " elements!\n";
} else { print "insufficient elements. fail.\n";
}Ruby: x = 'Apple Carrot Banana' y = x.split(' ').sort if (y.size > 2) puts "we've got #{y.size} elements!"
else puts 'insufficient elements. fail.'
endRuby just seems more elegant to me, more programmer-friendly. YMMV. |