Skip to content

Instantly share code, notes, and snippets.

@igrep
Created September 18, 2010 09:40
Show Gist options
  • Save igrep/585529 to your computer and use it in GitHub Desktop.
Save igrep/585529 to your computer and use it in GitHub Desktop.
Try splatter operator for an IO.
#!/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
#!/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