SlideShare a Scribd company logo
1 of 27
Download to read offline
New Features
in Ruby 2.4
Ireneusz Skrobiś
Lead Developer @ Selleo
New #sum method for Enumerable
New #sum method for Enumerable
[1, 1, 2, 3, 5, 8, 13, 21].sum # => 54
New #sum method for Enumerable
[1, 1, 2, 3, 5, 8, 13, 21].sum # => 54
The #sum method has an optional parameter which defaults to 0.
This value is the starting value of a summation meaning that [].sum is 0.
Faster Array#min and Array#max
Faster Array#min and Array#max
Array#min: 35.1 i/s
Enumerable#min: 21.8 i/s - 1.61x slower
Extract named captures from Regexp match results
Extract named captures from Regexp match results
pattern = /(?<first_name>John) (?<last_name>w+)/
pattern.match('John Backus').named_captures
# => {"first_name" => "John", "last_name" => "Backus"}
Extract named captures from Regexp match results
pattern = /(?<first_name>John) (?<last_name>w+)/
pattern.match('John Backus').named_captures
# => {"first_name" => "John", "last_name" => "Backus"}
pattern =
/(?<year>d{4})-(?<month>d{2})-(?<day>d{2})/
pattern.match('2016-02-01').values_at(:year, :month)
# => ["2016", "02"]
Faster regular expressions with Regexp#match?
Faster regular expressions with Regexp#match?
Regexp#match?: 2630002.5 i/s
Regexp#===: 872217.5 i/s - 3.02x slower
Regexp#=~: 859713.0 i/s - 3.06x slower
Regexp#match: 539361.3 i/s - 4.88x slower
New methods for testing if directories/files are empty
New methods for testing if directories/files are empty
Dir.empty?('empty_directory') # => true
Dir.empty?('directory_with_files') # => false
File.empty?('contains_text.txt') # => false
File.empty?('empty.txt') # => true
New Integer#digits method
New Integer#digits method
123.digits # => [3, 2, 1]
123.digits[0] # => 3
New Integer#digits method
123.digits # => [3, 2, 1]
123.digits[0] # => 3
# Equivalent behavior in Ruby 2.3:
123.to_s.chars.map(&:to_i).reverse # => [3, 2, 1]
Moves configuration to Logger’s constructor
Moves configuration to Logger’s constructor
logger = Logger.new(STDOUT, level: :info, progname: 'LOG')
Moves configuration to Logger’s constructor
logger = Logger.new(STDOUT, level: :info, progname: 'LOG')
# Equivalent behavior in Ruby 2.3:
logger = Logger.new(STDOUT)
logger.level = :info
logger.progname = 'LOG'
Simplified integers
Simplified integers
# Find classes which subclass the base "Numeric" class:
numerics = ObjectSpace.each_object(Module).select { |mod| mod < Numeric }
Simplified integers
# Find classes which subclass the base "Numeric" class:
numerics = ObjectSpace.each_object(Module).select { |mod| mod < Numeric }
# In Ruby 2.3:
numerics # => [Complex, Rational, Bignum, Float, Fixnum, Integer, BigDecimal]
Simplified integers
# Find classes which subclass the base "Numeric" class:
numerics = ObjectSpace.each_object(Module).select { |mod| mod < Numeric }
# In Ruby 2.3:
numerics # => [Complex, Rational, Bignum, Float, Fixnum, Integer, BigDecimal]
# In Ruby 2.4:
numerics # => [Complex, Rational, Float, Integer, BigDecimal]
New arguments supported for float modifiers
New arguments supported for float modifiers
4.55.ceil(1) # => 4.6
4.55.floor(1) # => 4.5
4.55.truncate(1) # => 4.5
4.55.round(1) # => 4.6
You can find more information here
https://blog.blockscore.com/new-features-in-ruby-2-4/
Thank you!
Live long and prosper :)
Ireneusz Skrobiś
Lead Developer @ Selleo

More Related Content

What's hot (20)

C Homework Help
C Homework HelpC Homework Help
C Homework Help
 
Merging tables using R
Merging tables using R Merging tables using R
Merging tables using R
 
Doubly linked list (animated)
Doubly linked list (animated)Doubly linked list (animated)
Doubly linked list (animated)
 
Python programming –part 7
Python programming –part 7Python programming –part 7
Python programming –part 7
 
Windows power shell basics
Windows power shell basicsWindows power shell basics
Windows power shell basics
 
Python programming -Tuple and Set Data type
Python programming -Tuple and Set Data typePython programming -Tuple and Set Data type
Python programming -Tuple and Set Data type
 
Perl one liners
Perl one linersPerl one liners
Perl one liners
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
 
Python Homework Help
Python Homework HelpPython Homework Help
Python Homework Help
 
Matlab functions
Matlab functionsMatlab functions
Matlab functions
 
PHP Mailer Remote Code Execution
PHP Mailer Remote Code ExecutionPHP Mailer Remote Code Execution
PHP Mailer Remote Code Execution
 
Itroroduction to R language
Itroroduction to R languageItroroduction to R language
Itroroduction to R language
 
11 15 (doubly linked list)
11 15 (doubly linked list)11 15 (doubly linked list)
11 15 (doubly linked list)
 
Python programming : List and tuples
Python programming : List and tuplesPython programming : List and tuples
Python programming : List and tuples
 
Pipes and filters
Pipes and filtersPipes and filters
Pipes and filters
 
Linkedlist
LinkedlistLinkedlist
Linkedlist
 
Iteration
IterationIteration
Iteration
 
Linked list
Linked listLinked list
Linked list
 
Parallel arrays in python
Parallel arrays in pythonParallel arrays in python
Parallel arrays in python
 
Intro to ReactiveCocoa
Intro to ReactiveCocoaIntro to ReactiveCocoa
Intro to ReactiveCocoa
 

Similar to New features in Ruby 2.4

Chapter 22. Lambda Expressions and LINQ
Chapter 22. Lambda Expressions and LINQChapter 22. Lambda Expressions and LINQ
Chapter 22. Lambda Expressions and LINQIntro C# Book
 
RubyEnRails2007 - Dr Nic Williams - DIY Syntax
RubyEnRails2007 - Dr Nic Williams - DIY SyntaxRubyEnRails2007 - Dr Nic Williams - DIY Syntax
RubyEnRails2007 - Dr Nic Williams - DIY SyntaxDr Nic Williams
 
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnNumerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnArnaud Joly
 
R is a very flexible and powerful programming language, as well as a.pdf
R is a very flexible and powerful programming language, as well as a.pdfR is a very flexible and powerful programming language, as well as a.pdf
R is a very flexible and powerful programming language, as well as a.pdfannikasarees
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleRaimonds Simanovskis
 
Java script advance-auroskills (2)
Java script advance-auroskills (2)Java script advance-auroskills (2)
Java script advance-auroskills (2)BoneyGawande
 
Ruby on Rails Intro
Ruby on Rails IntroRuby on Rails Intro
Ruby on Rails Introzhang tao
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN StackTroy Miles
 
Background Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbBackground Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbJuan Maiz
 
React Native One Day
React Native One DayReact Native One Day
React Native One DayTroy Miles
 
Python lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionPython lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionARVIND PANDE
 
PowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdfPowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdfoutcast96
 
Day 1c access, select ordering copy.pptx
Day 1c   access, select   ordering copy.pptxDay 1c   access, select   ordering copy.pptx
Day 1c access, select ordering copy.pptxAdrien Melquiond
 
PHP record- with all programs and output
PHP record- with all programs and outputPHP record- with all programs and output
PHP record- with all programs and outputKavithaK23
 

Similar to New features in Ruby 2.4 (20)

Chapter 22. Lambda Expressions and LINQ
Chapter 22. Lambda Expressions and LINQChapter 22. Lambda Expressions and LINQ
Chapter 22. Lambda Expressions and LINQ
 
RubyEnRails2007 - Dr Nic Williams - DIY Syntax
RubyEnRails2007 - Dr Nic Williams - DIY SyntaxRubyEnRails2007 - Dr Nic Williams - DIY Syntax
RubyEnRails2007 - Dr Nic Williams - DIY Syntax
 
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnNumerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
 
R is a very flexible and powerful programming language, as well as a.pdf
R is a very flexible and powerful programming language, as well as a.pdfR is a very flexible and powerful programming language, as well as a.pdf
R is a very flexible and powerful programming language, as well as a.pdf
 
R programming
R programmingR programming
R programming
 
Fast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on OracleFast Web Applications Development with Ruby on Rails on Oracle
Fast Web Applications Development with Ruby on Rails on Oracle
 
Headless Js Testing
Headless Js TestingHeadless Js Testing
Headless Js Testing
 
Java script advance-auroskills (2)
Java script advance-auroskills (2)Java script advance-auroskills (2)
Java script advance-auroskills (2)
 
Ruby on Rails Intro
Ruby on Rails IntroRuby on Rails Intro
Ruby on Rails Intro
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN Stack
 
DIWE - Advanced PHP Concepts
DIWE - Advanced PHP ConceptsDIWE - Advanced PHP Concepts
DIWE - Advanced PHP Concepts
 
Background Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRbBackground Jobs - Com BackgrounDRb
Background Jobs - Com BackgrounDRb
 
React Native One Day
React Native One DayReact Native One Day
React Native One Day
 
Python lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce functionPython lambda functions with filter, map & reduce function
Python lambda functions with filter, map & reduce function
 
PowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdfPowerShell_LangRef_v3 (1).pdf
PowerShell_LangRef_v3 (1).pdf
 
Python lecture 05
Python lecture 05Python lecture 05
Python lecture 05
 
07. Arrays
07. Arrays07. Arrays
07. Arrays
 
Day 1c access, select ordering copy.pptx
Day 1c   access, select   ordering copy.pptxDay 1c   access, select   ordering copy.pptx
Day 1c access, select ordering copy.pptx
 
PHP record- with all programs and output
PHP record- with all programs and outputPHP record- with all programs and output
PHP record- with all programs and output
 

More from Ireneusz Skrobiś

Bugs and non-technical client
Bugs and non-technical clientBugs and non-technical client
Bugs and non-technical clientIreneusz Skrobiś
 
PayPal Subscriptions in Ruby on Rails application
PayPal Subscriptions in Ruby on Rails applicationPayPal Subscriptions in Ruby on Rails application
PayPal Subscriptions in Ruby on Rails applicationIreneusz Skrobiś
 
How to introduce a new developer to a project.
How to introduce a new developer to a project.How to introduce a new developer to a project.
How to introduce a new developer to a project.Ireneusz Skrobiś
 
Geolocation Databases in Ruby on Rails
Geolocation Databases in Ruby on RailsGeolocation Databases in Ruby on Rails
Geolocation Databases in Ruby on RailsIreneusz Skrobiś
 
Geocoding with Rails and Twitter Typeahead
Geocoding with Rails and Twitter TypeaheadGeocoding with Rails and Twitter Typeahead
Geocoding with Rails and Twitter TypeaheadIreneusz Skrobiś
 
LOL vs Dota2: Battle Of APIs
LOL vs Dota2: Battle Of APIsLOL vs Dota2: Battle Of APIs
LOL vs Dota2: Battle Of APIsIreneusz Skrobiś
 
What to do when there is no API
What to do when there is no APIWhat to do when there is no API
What to do when there is no APIIreneusz Skrobiś
 

More from Ireneusz Skrobiś (8)

Bugs and non-technical client
Bugs and non-technical clientBugs and non-technical client
Bugs and non-technical client
 
PayPal Subscriptions in Ruby on Rails application
PayPal Subscriptions in Ruby on Rails applicationPayPal Subscriptions in Ruby on Rails application
PayPal Subscriptions in Ruby on Rails application
 
New features in Ruby 2.5
New features in Ruby 2.5New features in Ruby 2.5
New features in Ruby 2.5
 
How to introduce a new developer to a project.
How to introduce a new developer to a project.How to introduce a new developer to a project.
How to introduce a new developer to a project.
 
Geolocation Databases in Ruby on Rails
Geolocation Databases in Ruby on RailsGeolocation Databases in Ruby on Rails
Geolocation Databases in Ruby on Rails
 
Geocoding with Rails and Twitter Typeahead
Geocoding with Rails and Twitter TypeaheadGeocoding with Rails and Twitter Typeahead
Geocoding with Rails and Twitter Typeahead
 
LOL vs Dota2: Battle Of APIs
LOL vs Dota2: Battle Of APIsLOL vs Dota2: Battle Of APIs
LOL vs Dota2: Battle Of APIs
 
What to do when there is no API
What to do when there is no APIWhat to do when there is no API
What to do when there is no API
 

Recently uploaded

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAbhinavSharma374939
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 

Recently uploaded (20)

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Analog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog ConverterAnalog to Digital and Digital to Analog Converter
Analog to Digital and Digital to Analog Converter
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 

New features in Ruby 2.4

  • 1. New Features in Ruby 2.4 Ireneusz Skrobiś Lead Developer @ Selleo
  • 2. New #sum method for Enumerable
  • 3. New #sum method for Enumerable [1, 1, 2, 3, 5, 8, 13, 21].sum # => 54
  • 4. New #sum method for Enumerable [1, 1, 2, 3, 5, 8, 13, 21].sum # => 54 The #sum method has an optional parameter which defaults to 0. This value is the starting value of a summation meaning that [].sum is 0.
  • 6. Faster Array#min and Array#max Array#min: 35.1 i/s Enumerable#min: 21.8 i/s - 1.61x slower
  • 7. Extract named captures from Regexp match results
  • 8. Extract named captures from Regexp match results pattern = /(?<first_name>John) (?<last_name>w+)/ pattern.match('John Backus').named_captures # => {"first_name" => "John", "last_name" => "Backus"}
  • 9. Extract named captures from Regexp match results pattern = /(?<first_name>John) (?<last_name>w+)/ pattern.match('John Backus').named_captures # => {"first_name" => "John", "last_name" => "Backus"} pattern = /(?<year>d{4})-(?<month>d{2})-(?<day>d{2})/ pattern.match('2016-02-01').values_at(:year, :month) # => ["2016", "02"]
  • 10. Faster regular expressions with Regexp#match?
  • 11. Faster regular expressions with Regexp#match? Regexp#match?: 2630002.5 i/s Regexp#===: 872217.5 i/s - 3.02x slower Regexp#=~: 859713.0 i/s - 3.06x slower Regexp#match: 539361.3 i/s - 4.88x slower
  • 12. New methods for testing if directories/files are empty
  • 13. New methods for testing if directories/files are empty Dir.empty?('empty_directory') # => true Dir.empty?('directory_with_files') # => false File.empty?('contains_text.txt') # => false File.empty?('empty.txt') # => true
  • 15. New Integer#digits method 123.digits # => [3, 2, 1] 123.digits[0] # => 3
  • 16. New Integer#digits method 123.digits # => [3, 2, 1] 123.digits[0] # => 3 # Equivalent behavior in Ruby 2.3: 123.to_s.chars.map(&:to_i).reverse # => [3, 2, 1]
  • 17. Moves configuration to Logger’s constructor
  • 18. Moves configuration to Logger’s constructor logger = Logger.new(STDOUT, level: :info, progname: 'LOG')
  • 19. Moves configuration to Logger’s constructor logger = Logger.new(STDOUT, level: :info, progname: 'LOG') # Equivalent behavior in Ruby 2.3: logger = Logger.new(STDOUT) logger.level = :info logger.progname = 'LOG'
  • 21. Simplified integers # Find classes which subclass the base "Numeric" class: numerics = ObjectSpace.each_object(Module).select { |mod| mod < Numeric }
  • 22. Simplified integers # Find classes which subclass the base "Numeric" class: numerics = ObjectSpace.each_object(Module).select { |mod| mod < Numeric } # In Ruby 2.3: numerics # => [Complex, Rational, Bignum, Float, Fixnum, Integer, BigDecimal]
  • 23. Simplified integers # Find classes which subclass the base "Numeric" class: numerics = ObjectSpace.each_object(Module).select { |mod| mod < Numeric } # In Ruby 2.3: numerics # => [Complex, Rational, Bignum, Float, Fixnum, Integer, BigDecimal] # In Ruby 2.4: numerics # => [Complex, Rational, Float, Integer, BigDecimal]
  • 24. New arguments supported for float modifiers
  • 25. New arguments supported for float modifiers 4.55.ceil(1) # => 4.6 4.55.floor(1) # => 4.5 4.55.truncate(1) # => 4.5 4.55.round(1) # => 4.6
  • 26. You can find more information here https://blog.blockscore.com/new-features-in-ruby-2-4/
  • 27. Thank you! Live long and prosper :) Ireneusz Skrobiś Lead Developer @ Selleo