wilson (owner)

Revisions

gist: 156671 Download_button fork
public
Public Clone URL: git://gist.github.com/156671.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
words = %w(one two three lol zarglezargle one two six jambo)
p words.select {|word| word if (word.length > 3)..(word.length > 5) }
 
# output:
# ["three", "lol", "zarglezargle", "jambo"]
# 'one' and 'two' are skipped because they are not > 3 characters in length
# 'three' triggers the left side of the flip-flop condition
# 'lol' is selected because the left side has triggered, but not the right side
# 'zarglezargle' triggers the right side condition, and 'turns off' the flip-flop
# Because we used '..' here instead of '...' in the flip-flop, the condition returns true
# This code, with '...', would leave 'zarglezargle' out of the output
# The flip-flop is now off, so 'one', 'two', and 'six' are skipped.
# Finally, 'jambo' re-triggers the flip-flop