Created
June 2, 2010 06:35
-
-
Save bodhi/422030 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, ""] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
x = [nil,nil,nil]
x.pop when x.last.blank? #=> dead loop