Thanks, finally someone said the magic words... "never say never", that's the whole point of this pro-tip..
Thanks for your comments, I appreciate your input and I do agree with you in all of those points, but I have come to use this in some cases, so I thought I'd share it here.
@epocsquadron You're right, if you have zencoding and you're doing this on an html file, they key combo will bring up the zencoding input box for you to use. Awesome tip!
Hey, cool tip, just wanted to point something out:
Technically, without attr_accessor, you could still do:
class Phone
def model= ( model )
write_attribute(:model, model)
end
def model
@model
end
end
And use it just as if you would've used attr_accessor:
require './Phone' #! import class
myphone = Phone.new #! instantiate class Phone
myphone.model = "iPhone5" #! set model name
myphone.model #! get model name
That's actually a very nice tip! Thanks for sharing!
Great tip, but it can very well apply to all look-ups. If you're repeating the same selector on every line, just cache it on a variable and reuse the object returned the first time.
Indeed :)