#ruby-lang - Sun 25 Mar 2007 between 19:54 and 20:55

NY Lost Funds



steer:)
a
meekishAria: Would this work as a convenience method? http://pastie.caboo.se/49454
steerAria has quit
possibly by error
ahFeel`teferi > available for some help ? :)
djwonki want to do `a=[1,2,3]; a.each {|x| x += 1 }` to get [2,3,4]
but it appears that changing the block parameter doesn't affect the original. perhaps there is a dup going on
mrakis there a way to rewrite this? http://pastie.caboo.se/49460
ahFeel`djwonk a.map
:)
actually
a.map!
to be right
:)
djwonkahFeel`: thanks!
ahFeel`np ;)
djwonkmrak: I would use find_by_name instead of find ... :conditions
mrakdjwonk, you're right
but I was actually wondering how to extract only the name field
without the additional if
djwonkmrak: but you probably want to be DRYer with your plethora of @selected's right?
mrakyep
djwonkpersonally, I would do tag = Tag.find_by_name... ; @name = tag.name if tag
and check the error condition ; i.e. what happens if you don't find a tag (make sure you handle that)
trying to condense the logic too much might tempt you to not think about edge conditions
to make it really brief, you could write: @selected = Tag.find_by_name(params[:tag]).name
but if the find fails, you'll end up with `nil.name`
mrakyeah, that's why I have this additional if
ahFeel`Anyone experienced with extending Ruby with C ?
ecinmrak: @selected ||= @selected.name if you want to save about 10 characters.
But that doesn't reduce the need for it.
slapahohey guys, i see a lot of old school OO developers name methods/attributes with verbs at the beginning. like, user.isEmployed and user.getJob. seems this convention isn't followed in ruby/rails. any thoughts why?
ahFeel`the language allows more flexible names
ecinWe can use question marks!
ahFeel`like
user.employed?
:)
ecinRight.
slapahoyea, duh, great point

Page: 5 12 19 26 33 40 47 54 

IrcArchive

NY Lost Funds