Ruby opinions (111)

51 Name: Squeeks : 2007-07-09 00:50 ID:agPxiYUm

I'm going to repeat a few things already said here, but I need to bitch about Ruby for a while.

#{}
# is a character solely reserved for commenting. I totally understand the need for using "unique" characters so you can interpolate objects in a string, but find some other characters to do the fucking job. puts "#{foo} - #{bar}, #{moreoffoo}" etc is just dumb.

Incrementals (++ and --)
Someone explained the reason for these not to exist is because in the OO world, an object's incremental increase might not be just "1". Hah? Either way, putting it something that just adds/removes 1 to an object that is a known integer is much nicer than foo +=1 in my loops.

Not so nil
One bad programming habit in other people's code I find pop up is failing to return nil if an error occurs. This means of course, that when I assign the value of an object to a method that causes it, things break only when I try to use the said object, because it has an empty value. Hpricot, is a big one to blame. Acessing a specific element that does not exist in a block of HTML will return "". This result is considered "true", so:

foo = Hpricot(lol_webpage/"div.bullshit".to_s)
Someclass.method(foo) if foo

Will always call the method. I've gotta work around it with Someclass.method(foo) if foo = ''.

Name: Link:
Leave these fields empty (spam trap):
More options...
Verification: