Read more

Unindent HEREDOCs in Ruby 2.3

Henning Koch
December 22, 2015Software engineer at makandra GmbH

In Ruby 2.3 you can use <<~ instead of <<- to automatically remove indentation from a HEREDOCs:

str = <<~MESSAGE
  Hello Universe!
  This is me.
             Bye!
MESSAGE
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

str will now be:

Hello Universe!
This is me.
           Bye!
Posted by Henning Koch to makandra dev (2015-12-22 19:28)