Whats new in Ruby 2.3
@h6165
Abhishek Yadav
ரூபீ ப்ரோக்ராமர்
Co-organizer: Chennai.rb
Whats new in Ruby 2.3
h = { a: 2,
b: { x: 20, y: 30 },
c: { m: { today: :me, tomorrow: :you },
n: :hello }}
h.dig(:c, :m, :today) # => :me
h.dig(:a, :m, :today) # => nil
Hash#dig
Whats new in Ruby 2.3
A = Struct.new(:foo)
a = [A.new(20), nil].sample
## earlier
b = a && a.foo
## Now
b = a&.foo
Lonely operator
(safe navigation operator)
Whats new in Ruby 2.3
h = { a: 2,
b: { x: 20, y: 30 },
c: { m: { today: :me, tomorrow: :you },
n: "hello" }
}
h.fetch_values(:a, :b) # => [2, {:x=>20, :y=>30}]
Hash#fetch_values
Whats new in Ruby 2.3
Classy.new
NameError: uninitialized constant Classy
Did you mean? Class
did_you_mean?
Whats new in Ruby 2.3
list = ['Ruby', 'Elixir', 'Python']
list.grep(/y/)
list.grep_v(/y/)
grep_v
Whats new in Ruby 2.3
h = { a: 2, b: 3, c: 4}
[:b, :c].map(&h) #=> [2, 3]
Hash#to_proc
Whats new in Ruby 2.3
# frozen_string_literal: true
str = 'hello'
str[0] = 'H' #=> RuntimeError: can't modify frozen String
frozen_string_literal
Whats new in Ruby 2.3
ISeq serialize objects
-
Additions to RubyVM::InstructionSequence:
-
RubyVM::InstructionSequence#to_binary_format
-
RubyVM::InstructionSequence.from_binary_format(data)
-
-
Goal: machine dependent binaries:
- fast bootstrap time for big applications
- reduce memory consumption with several techniques
-
Not:
- packing scripts to one package
- to hide source code
- Experimental currently. With security risks
Whats new in Ruby 2.3
Refs:
- http://nithinbekal.com/posts/ruby-2-3-features/
- https://www.ruby-lang.org/en/news/2015/12/25/ruby-2-3-0-released/
- https://bugs.ruby-lang.org/issues/11788
- https://docs.google.com/document/d/1D0Eo5N7NE_unIySOKG9lVj_eyXf66BQPM4PKp7NvMyQ/pub
@h6165
Abhishek Yadav
ரூபீ ப்ரோக்ராமர்
Co-organizer: Chennai.rb
Whats new in Ruby 2.3
By Abhishek Yadav
Whats new in Ruby 2.3
- 1,108