On May 18, 2011, at 11:19 AM, James Miller wrote:

I'm preparing slides for next week's Intro to Ruby class and wanted to get some opinions on 1.9 syntax.

I want to encourage the use of 1.9 and teach the new syntax while referencing the old, but I'm on the fence about hashes where the values are symbols and I'm curious as to what people are doing:

hash = {foo: :bar, this: :that}
or in Rails
has_many :users, through: :accounts, dependent: :destroy

Ok? No way? Use a mix of the syntaxes depending on whether the values are non-symbols (yuck)?

I've always thought => was heavy and noisy, but {foo: :bar, this: :that} looks too much like an array to me. So, I'm a fence sitter too.

However, during the past few years I've learned several languages new to me, and I have noticed something: when I worked solely with one main language, I got pretty fervent about "the right way." As I've grown accustomed to different languages, I've given up, err, I mean calmed down on worrying about that stuff. I used to despise with a passion upper case CONSTANTS. What a visually stupid thing to do to code. So, now I just despise it, and I've set aside the passion ;-) I try to save the passion for structure and architecture.

The new syntax exists. Some will hate it, some will prefer it. Your students will end up seeing it, so you may as well introduce it and you may as well set the foundation that either is OK.

-- gw

--
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby

Reply via email to