4 ms·
My big takeaway is that Ruby generally does things the "most-popular" way, and that maybe a lot of those obscure languages are obscure for a reason (object["met
by brittohalloran 14y ago
My big takeaway is that Ruby generally does things the "most-popular" way, and that maybe a lot of those obscure languages are obscure for a reason (object["method"](params) to invoke a method?!?)
- walrus 14y agoobject["method"](params) is just an alternative syntax. Normally you would do object->method(params).
- ajanuary 14y agoYou mean like JavaScript? Not sure why it's not listed there next to Pike. var f = [] f['push'](2) // f -> [2] Pike also has the more familiar object->method(params) syntax. It's actually a pretty useful bit of syntax. I've been using it recently when combining multiple objects deserialised from json. var report = [name, dob] var person = { name: 'Andrew', dob: '1980/03/23' } _.each(report, function(prop) { console.log(person[prop]) }
- wilmoore 14y agoGood call...and for those not necessarily using something underscore.js-like (thought almost always nice-to-have): var report = ['name', 'dob']; var person = { name: 'Andrew', dob: '1980/03/23' }; report.forEach(function(prop){ console.log(person[prop]); });
- rll 14y agoNot sure about that. The regex for variable identifiers shows that Ruby is alone on the island of languages that force a lowercase first character.
- aaronblohowiak 14y agoGo uses casing for semantic meaning as well. Also, you can use non-A-Z in ruby source. http://rosettacode.org/wiki/Unicode_variable_names#Ruby http://rosettacode.org/wiki/Unicode_variable_names#Ruby
- objclxt 14y agoGo is missing from the analysis (sadly, because it's definitely more popular than some of the languages listed!) - but yes, casing is used to determine the scope of your variables. It's actually a rather elegant solution (I find Go's syntax to be generally elegant, but YMMV)