For example:
code = <<-EOH bundle install bundle exec unicorn -c /etc/unicorn.cfg -D EOH
What does this code do? What is <<-
called?
In ruby '<<' operator is basically used for: Appending a value in the array (at last position) [2, 4, 6] << 8 It will give [2, 4, 6, 8] It also used for some active record operations in ruby.
It lets you add items to a collection or even concatenate strings.
Code in <% %> (without equal) is executed "with no substitution back into the output" means you want to execute code WITHOUT any output, like a loop and the best part is, it can be used with a non ruby code.
It's called heredoc. An easy way to define multiline strings which may include single or double quotes without needing to escape them.
See more here, for example.
Often you use heredocs to define large chunks of code. Some editors know about this and can highlight syntax for you there (if you specify language). Look:
Looks to me like heredoc. The -
allows the ending delimiter to ignore whitespace before it.
A simple Google Search gave me this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With