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

View all comments

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