in reply to Perl is more intuitive
You can write the ruby code for hashes a lot more intuitively like so:
#!/usr/bin/ruby # example data hash = { 'a' => '1', 'b' => '2', 'c' => '3', } hash.each do | k, v | puts "#{k} - #{v}<br/>" end
Update for the interested: ruby does have sigils, but they denote "scope" instead of "type": $ - global, @ - instance property and @@ - "static" class property. No sigil basically means lexical scope (automatic variable).
The reasoning behind this probably is, that variables that can be declared "somewhere else" in the code have sigils, but "local" variables don't need sigils since you can see that they are variables because they're declared a close by. In some respects ruby is even more fanatic about saving characters than perl :-) That there is no way to distinguish "type" by sigil is a good thing - since it makes it a lot easier to emulate the built-in types' API with user-defined classes.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl is more intuitive
by kiat (Vicar) on Aug 19, 2005 at 11:44 UTC | |
by Joost (Canon) on Aug 19, 2005 at 11:57 UTC | |
by kiat (Vicar) on Aug 19, 2005 at 13:44 UTC | |
by Joost (Canon) on Aug 19, 2005 at 14:08 UTC |