Close
Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

LABS
NY Standup 6/3/2011: Reading and Rainbows

Interesting Things

  • A more readable Solarized: Ethan Schoonover’s excellent color scheme Solarized is available for a number of applications, including iTerm 2. However, it can be hard to use in iTerm: the green looks yellow (bad for test output), the grey looks like the background (making RSpec backtraces disappear), and the selection highlight is barely visible. As Rajan points out, A fork by Wes Morgan fixes these problems. Wes also wins this week’s surprise award for best GitHub username.

  • git unpushed/unpulled: Kris wrote a couple of nice aliases to drop in your ~/.gitconfig. git unpushed shows the commits that you haven’t pushed to origin yet on your current branch. git unpulled shows the commits that are on origin’s version your current branch that you haven’t pulled down yet.

Dangerous

  • Random Rubyism: Newlee points out that assignment inside a conditional can be a funny thing. Sometimes people do this:

    if elephant = Savannah.look_for_elephant
      person.ride(elephant)
    else
      person.be_sad
    end
    

    That is, you can use assignment inside the conditional to put something in a variable and test for it existence at the same time. It’s a questionable practice, since it’s easy to mix up = and ==. Newlee, never one to give up easily, wanted to see just how questionable he could make it. What happens if you do this?

    person.ride(elephant) if elephant = Savannah.look_for_elephant
    

    If Savannah.look_for_elephant is truthy, you might get:

    NameError: undefined local variable or method `elephant'
    

    because it looks for elephant before the assignment takes place. That’s if you haven’t defined elephant yet. If there’s an existing local, you’ll get its value before the assignment in the if, and if there’s no local but there’s a method elephant, you’ll call the method.

    If Savannah.look_for_elephant is falsy, though, Person#ride will never get called. This means that Ruby first determines how to evaluate the left side of the statement, then evaluates the conditional, then (if the conditional is truthy) actually evaluates the the left side according to the way it was originally parsed.

    Weird.

Other

  • This week’s surprise award for best shirt is split: congratulations to Ian “Zabes” Zabel and Lee “Newlee” Edwards!

Comments
Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *