Skip to content

Instantly share code, notes, and snippets.

@jcinnamond
Last active October 13, 2015 17:12
Show Gist options
  • Save jcinnamond/d20457e7619ac32e9e68 to your computer and use it in GitHub Desktop.
Save jcinnamond/d20457e7619ac32e9e68 to your computer and use it in GitHub Desktop.

In my Extreme Object-Oriented Ruby talk at Full Stack Fest there was a bug in the live coding at around 29 minutes. When I was running the code it was failing with undefined method 'then' for false:FalseClass.

The source of the bug is quite subtle. The boolean operator starts with:

If.new(threat_level == Four)

That looks like it should work, but ten minutes earlier (when I'd been writing the comparisons for numbers) I forgot to save the file before moving on. The live evaluation worked when I was looking at numbers because it copies the content from my editor, runs it through xmpfilter and then puts the result back into the editor, so it doesn't require me to save the file. But later on when I was using the number for this comparison it became a problem. The comparison fell back to Ruby's built-in behaviour for == which, in this case, was returning Ruby's built in false rather than an instance of the False class that I had written.

This means that when it tried to evaluate the If code, it tried to call then on false. This method doesn't exist, so it raised the exception you see on screen. This source of this error is a long way from the code I was writing. Live coding is hard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment