Jeff Dean's blog
Interesting Things
Truthiness
You can't make something "falsy" in ruby. For example, let's say you are a good Fowlerite and you are implementing a nil object pattern like so:
class User; end class NilUser def nil?() true end end user = NilUser.new if user puts "Access Approved" else puts "Access Denied" end
If you run that code, even though you've defined .nil? to be true, it will print "Access Approved". Ruby if/unless/else only recognize nil and false to be "falsey".
RubyMine rebase strangeness
When you rebase from the command line and get a merge error, then run the merge tool from RubyMine, the "Your changes" and "Their changes" will be the reverse of what you might think. If you are accustomed to clicking "accept theirs" to mean taking other people's changes, you'll be in for a surprise.
If you botch the git rebase, you can always go back with this awesome git command, brought to you by Peter Jaros:
git reset --hard "master@{ 1 }"
Interesting
While this has been mentioned before, naming an ActiveRecord association :target will cause infinite recursion. Especially lame if you are building an app for assassins or mobsters.
The tracker team upgraded to 2.2 and saw a big increase in the size of their mongrels, and much longer start-up times.
In an erector widget it appears that respond_to? checks arity. For example:
self.respond_to?("some_method") # => false
self.respond_to?("some_method", some_value) # => true
Interesting Things
When you specify a gem from a custom source, and it has dependencies on a separate source, you need to list both sources in geminstaller.yml.
This comes up when you are installing a gem from github and that gem depends on other gems from rubyforge. You can specify multiple sources by adding more --source attributes.







