r/ruby • • Dec 25 '15

Ruby 2.3.0 released

https://www.ruby-lang.org/en/news/2015/12/25/ruby-2-3-0-released/
132 Upvotes

6 comments sorted by

3

u/hak8or Dec 25 '15 edited Dec 25 '15

A Frozen String Literal Pragma is introduced. With Ruby 2.1, "str".freeze has been optimized to reduce object allocation. Ruby 2.3 introduces a new magic comment and command line option to freeze all string literals in the source files. Additionally for debugging, you can get where the object is created on "can't modify frozen String" error by --debug=frozen-string-literal command line option.

So they have constants for only strings? Why not put in a const keyword of sorts, or let freeze work on anything?

The did_you_mean gem is bundled. The did_you_mean gem shows the candidates on the NameError and NoMethodError to ease debugging.

Took a while, but wait, this gem is part of the languag or standard library?

The performance updates are most welcome though.

5

u/gwern- Dec 25 '15

let freeze work on anything

It does

2

u/hak8or Dec 25 '15

Oh awesome! I probably should have actually googled around first.

3

u/gwern- Dec 25 '15

Yup. Also checkout https://github.com/dkubb/ice_nine and https://github.com/dkubb/adamantium if you want good immutability

3

u/rfdonnelly Dec 26 '15

The best addition didn't make it to the announcement.

From: https://github.com/ruby/ruby/blob/v2_3_0/NEWS

* indented here document:

  * new string literal, here document starts with `<<~`.
    refer doc/syntax/literals.rdoc for more details.
    [Feature #9098]

From: https://github.com/ruby/ruby/blob/v2_3_0/doc/syntax/literals.rdoc

To have indented content as well as an indented closing identifier, you can use a “squiggly” heredoc, which uses a “~” instead of a “-” after <<:

expected_result = <<~SQUIGGLY_HEREDOC
  This would contain specially formatted text.

  That might span many lines
SQUIGGLY_HEREDOC

The indentation of the least-indented line will be removed from each line of the content. Note that empty lines and lines consisting solely of literal tabs and spaces will be ignored for the purposes of determining indentation, but escaped tabs and spaces are considered non-indentation characters.

0

u/[deleted] Dec 27 '15

Very less features added. Is there any performance upgrade?