- print <<EOF
- The price is #{$Price}.
- EOF
- print <<"EOF"; # same as above
- The price is #{$Price}.
- EOF
- print <<`EOC` # execute commands
- echo hi there
- echo lo there
- EOC
- print <<"foo", <<"bar" # you can stack them
- I said foo.
- foo
- I said bar.
- bar
- myfunc(<<"THIS", 23, <<'THAT')
- Here's a line
- or two.
- THIS
- and here's another.
- THAT
- if need_define_foo
- eval <<-EOS # delimiters can be indented
- def foo
- print "foo\n"
- end
- EOS
- end
From: Ruby Language Reference Manual - Syntax
沒有留言:
張貼留言