Skip to content

Instantly share code, notes, and snippets.

@bodhi
Created June 2, 2010 06:35
Show Gist options
  • Save bodhi/422030 to your computer and use it in GitHub Desktop.
Save bodhi/422030 to your computer and use it in GitHub Desktop.
irb> x = [1,2,"",3, "", ""]
=> [1, 2, "", 3, "", ""]
irb> x.pop while x.last.blank?
=> nil
irb> x
=> [1, 2, "", 3]
irb> x = [1,2,"",3]
=> [1, 2, "", 3]
irb> x.pop while x.last.blank?
=> nil
irb> x
=> [1, 2, "", 3]
irb0> x = [1,2,"",3, "", ""]
=> [1, 2, "", 3, "", ""]
irb> x.pop until x.last.blank?
=> nil
irb> x
=> [1, 2, "", 3, "", ""]
irb> x = [1,2,"",3]
=> [1, 2, "", 3]
irb> x.pop until x.last.blank?
=> nil
irb> x
=> [1, 2, ""]
@kaichen
Copy link

kaichen commented Jun 2, 2010

x = [nil,nil,nil]
x.pop when x.last.blank? #=> dead loop

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