There's more than one way to do things | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
The ruby code you've written doesn't work for generic hashes (it does for arrays but it's not at all idiomatic).
You can write the ruby code for hashes a lot more intuitively like so:
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.
In reply to Re: Perl is more intuitive
by Joost
|
|