Created
September 18, 2010 09:40
-
-
Save igrep/585529 to your computer and use it in GitHub Desktop.
Try splatter operator for an IO.
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
#!/usr/bin/env ruby | |
# vim: set fileencoding=utf-8 : | |
$VERBOSE = true | |
##DIDN'T WORK!!## | |
#see( Japanese ) http://www.ruby-lang.org/ja/man/html/_C0A9B8E6B9BDC2A4.html#case | |
print 'foo/bar/hoge: ' | |
case gets #no chomp | |
when *DATA | |
puts 'former when caluse.' | |
when "foo\n" | |
puts 'latter when caluse.' | |
else | |
puts 'no match.' | |
end | |
__END__ | |
foo | |
bar | |
hoge |
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
#!/usr/bin/env ruby | |
# vim: set fileencoding=utf-8 : | |
$VERBOSE = true | |
=begin | |
Try splatter operator for an IO. | |
=end | |
def same_with_puts *args | |
puts( *args ) | |
end | |
#Prepare the diffrence | |
same_with_puts( DATA ) | |
same_with_puts( *DATA ) | |
__END__ | |
foo | |
bar | |
hoge |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment