SlideShare une entreprise Scribd logo
1  sur  29
Inside Enumerable ,[object Object],[object Object]
Agenda ,[object Object],[object Object],[object Object]
What is it? ,[object Object],[object Object],[object Object]
hash = { :a  => 1,  :b  => 2} hash.collect  do  |key, value|  value * 4 end [4,8] [4,8,12] [4,8,12] array = [1,2,3] array.collect  do  |value| value * 4 end range = 1..3 range.collect  do  |value| value * 4 end
hash = { :a  => 1,  :b  => 2} hash.collect  do  |key, value|  value * 4 end array = [1,2,3] array.collect  do  |value| value * 4 end range = 1..3 range.collect  do  |value| value * 4 end module  Enumerable def  collect ... end end
multiple inheritance
mixins
Mixins Cannot be instantiated Can be mixed in
Mixins usually  don’t stand alone don’t stand alone ,[object Object],[object Object],[object Object],[object Object],[object Object]
Enumerable requires each() [1,2,3].collect {|i| i*2} [2,4,6]
Enumerable.collect class  Foo include  Enumerable def  each yield 1 yield 2 yield 3 end end Foo.new.collect do |num| num * 2 end module  Enumerable def  collect array = [] each do |a| array <<  yield (a) end array end end
Enumerable.collect module  Enumerable def  collect array = [] each do |a| array <<  yield (a) end array end end class  Foo include  Enumerable def  each yield 1 yield 2 yield 3 end end Foo.new.collect do |num| num * 2 end
Enumerable.collect module  Enumerable def  collect array = [] each do |a| array <<  yield (a) end array end end class  Foo include  Enumerable def  each yield 1 yield 2 yield 3 end end Foo.new.collect do |num| num * 2 end
Enumerable.collect class  Foo include  Enumerable def  each yield 1 yield 2 yield 3 end end Foo.new.collect do |num| num * 2 end module  Enumerable def  collect array = [] each do |a| array <<  yield (a) end array end end
Enumerable.collect module  Enumerable def  collect array = [] each do |a| array <<  yield (a) end array end end class  Foo include  Enumerable def  each yield 1 yield 2 yield 3 end end Foo.new.collect do |num| num * 2 end
Enumerable.collect class  Foo include  Enumerable def  each yield 1 yield 2 yield 3 end end Foo.new.collect do |num| num * 2 end module  Enumerable def  collect array = [] each do |a| array <<  yield (a) end array end end Result [2,4,6]
Required methods ,[object Object],[object Object],[object Object],[object Object],Comparison operator
Enumerable methods all?, any?, collect, detect, each_cons, each_slice, each_with_index, entries, enum_cons, enum_slice, enum_with_index, find, find_all, grep, include?, inject, map, max, member?, min, partition, reject, select, sort, sort_by, to_a, to_set, zip
any? [1,2,3,4].any? {|a| a > 2} Returns true if this block... ...returns true for  any of these values
all? [1,2,3,4].all? {|a| a > 2} Returns true if this block... ...returns true for  ALL of these values
collect, map ,[object Object],[object Object],[1,2,3].collect {|i| i*2} [2,4,6]
find, detect ,[object Object],[object Object],[object Object]
find_all, select ,[object Object],[object Object],[object Object]
grep ,[object Object],[object Object],Case equality
Case equality ,[object Object],Case equality Regular equality
Case equality case myvar when 1..50 # do something when 51 # do something when /^+$/ # do something end Within the range This exact number Matches this regular expression Different kind of equality as a convenience in case statements
Case equality in grep [1,2,3].grep(1..50) [1,2,3].grep(51) [1,2,3].grep(/^+$/) Within the range This exact number Matches this regular expression
Wrap up ,[object Object],[object Object],[object Object]
Shameless Plug ,[object Object],[object Object]

Contenu connexe

Tendances (20)

List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
 
2.4 multiplication of real numbers 1
2.4 multiplication of real numbers 12.4 multiplication of real numbers 1
2.4 multiplication of real numbers 1
 
List , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in pythonList , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in python
 
C# Arrays
C# ArraysC# Arrays
C# Arrays
 
Python for Beginners(v3)
Python for Beginners(v3)Python for Beginners(v3)
Python for Beginners(v3)
 
Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung FuPython quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fu
 
Introduction to python programming 2
Introduction to python programming   2Introduction to python programming   2
Introduction to python programming 2
 
Higher Order Procedures (in Ruby)
Higher Order Procedures (in Ruby)Higher Order Procedures (in Ruby)
Higher Order Procedures (in Ruby)
 
Python programming : Arrays
Python programming : ArraysPython programming : Arrays
Python programming : Arrays
 
Introduction to python programming 1
Introduction to python programming   1Introduction to python programming   1
Introduction to python programming 1
 
Python
PythonPython
Python
 
Numerical analysisgroup19
Numerical analysisgroup19Numerical analysisgroup19
Numerical analysisgroup19
 
Python PCEP Loops
Python PCEP LoopsPython PCEP Loops
Python PCEP Loops
 
Python programming workshop
Python programming workshopPython programming workshop
Python programming workshop
 
Arrays C#
Arrays C#Arrays C#
Arrays C#
 
Python numbers
Python numbersPython numbers
Python numbers
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Slicing in Python - What is It?
Slicing in Python - What is It?Slicing in Python - What is It?
Slicing in Python - What is It?
 
Pytho_tuples
Pytho_tuplesPytho_tuples
Pytho_tuples
 
Day2
Day2Day2
Day2
 

Similaire à Inside Enumerable

Functional techniques in Ruby
Functional techniques in RubyFunctional techniques in Ruby
Functional techniques in Rubyerockendude
 
Functional techniques in Ruby
Functional techniques in RubyFunctional techniques in Ruby
Functional techniques in Rubyerockendude
 
Puppet Language 4.0 - PuppetConf 2014
Puppet Language 4.0 - PuppetConf 2014Puppet Language 4.0 - PuppetConf 2014
Puppet Language 4.0 - PuppetConf 2014Puppet
 
RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0tutorialsruby
 
RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0tutorialsruby
 
C++ Searching & Sorting5. Sort the following list using the select.pdf
C++ Searching & Sorting5. Sort the following list using the select.pdfC++ Searching & Sorting5. Sort the following list using the select.pdf
C++ Searching & Sorting5. Sort the following list using the select.pdfRahul04August
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfinfo309708
 
golang_refcard.pdf
golang_refcard.pdfgolang_refcard.pdf
golang_refcard.pdfSpam92
 
Question 1,2,4 ------------------------------------Please check.pdf
Question 1,2,4 ------------------------------------Please check.pdfQuestion 1,2,4 ------------------------------------Please check.pdf
Question 1,2,4 ------------------------------------Please check.pdfanandhomeneeds
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfankit11134
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)Ishin Vin
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionarySoba Arjun
 
Groovy Refactoring Patterns
Groovy Refactoring PatternsGroovy Refactoring Patterns
Groovy Refactoring PatternsNaresha K
 

Similaire à Inside Enumerable (20)

Functional techniques in Ruby
Functional techniques in RubyFunctional techniques in Ruby
Functional techniques in Ruby
 
Functional techniques in Ruby
Functional techniques in RubyFunctional techniques in Ruby
Functional techniques in Ruby
 
Recursion Lecture in Java
Recursion Lecture in JavaRecursion Lecture in Java
Recursion Lecture in Java
 
Puppet Language 4.0 - PuppetConf 2014
Puppet Language 4.0 - PuppetConf 2014Puppet Language 4.0 - PuppetConf 2014
Puppet Language 4.0 - PuppetConf 2014
 
07+08slide.pptx
07+08slide.pptx07+08slide.pptx
07+08slide.pptx
 
F# array searching
F#  array searchingF#  array searching
F# array searching
 
Ruby basics
Ruby basicsRuby basics
Ruby basics
 
RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0
 
RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0RubyMiniGuide-v1.0_0
RubyMiniGuide-v1.0_0
 
Data structures Lecture 5
Data structures Lecture 5Data structures Lecture 5
Data structures Lecture 5
 
C++ Searching & Sorting5. Sort the following list using the select.pdf
C++ Searching & Sorting5. Sort the following list using the select.pdfC++ Searching & Sorting5. Sort the following list using the select.pdf
C++ Searching & Sorting5. Sort the following list using the select.pdf
 
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdfGetting StartedCreate a class called Lab8. Use the same setup for .pdf
Getting StartedCreate a class called Lab8. Use the same setup for .pdf
 
golang_refcard.pdf
golang_refcard.pdfgolang_refcard.pdf
golang_refcard.pdf
 
Twig tips and tricks
Twig tips and tricksTwig tips and tricks
Twig tips and tricks
 
Functional ruby
Functional rubyFunctional ruby
Functional ruby
 
Question 1,2,4 ------------------------------------Please check.pdf
Question 1,2,4 ------------------------------------Please check.pdfQuestion 1,2,4 ------------------------------------Please check.pdf
Question 1,2,4 ------------------------------------Please check.pdf
 
Please help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdfPlease help solve this in C++ So the program is working fin.pdf
Please help solve this in C++ So the program is working fin.pdf
 
Go Programming Language (Golang)
Go Programming Language (Golang)Go Programming Language (Golang)
Go Programming Language (Golang)
 
Python Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, DictionaryPython Variable Types, List, Tuple, Dictionary
Python Variable Types, List, Tuple, Dictionary
 
Groovy Refactoring Patterns
Groovy Refactoring PatternsGroovy Refactoring Patterns
Groovy Refactoring Patterns
 

Plus de Mike Bowler

Retrospective Magic - Toronto Agile Conference
Retrospective Magic - Toronto Agile ConferenceRetrospective Magic - Toronto Agile Conference
Retrospective Magic - Toronto Agile ConferenceMike Bowler
 
Retrospective science
Retrospective scienceRetrospective science
Retrospective scienceMike Bowler
 
Brain Talk: More effective conversations through clean language
Brain Talk: More effective conversations through clean languageBrain Talk: More effective conversations through clean language
Brain Talk: More effective conversations through clean languageMike Bowler
 
Continuous Delivery: Responding to Change Faster Than Ever Before - SDEC14
Continuous Delivery: Responding to Change Faster Than Ever Before - SDEC14Continuous Delivery: Responding to Change Faster Than Ever Before - SDEC14
Continuous Delivery: Responding to Change Faster Than Ever Before - SDEC14Mike Bowler
 
Continuous Delivery for Agile Teams
Continuous Delivery for Agile TeamsContinuous Delivery for Agile Teams
Continuous Delivery for Agile TeamsMike Bowler
 
Exploring the magic behind dynamic finders: diving into ActiveRecord::Base.me...
Exploring the magic behind dynamic finders: diving into ActiveRecord::Base.me...Exploring the magic behind dynamic finders: diving into ActiveRecord::Base.me...
Exploring the magic behind dynamic finders: diving into ActiveRecord::Base.me...Mike Bowler
 
Ruby For Java Programmers
Ruby For Java ProgrammersRuby For Java Programmers
Ruby For Java ProgrammersMike Bowler
 

Plus de Mike Bowler (8)

Retrospective Magic - Toronto Agile Conference
Retrospective Magic - Toronto Agile ConferenceRetrospective Magic - Toronto Agile Conference
Retrospective Magic - Toronto Agile Conference
 
Retrospective science
Retrospective scienceRetrospective science
Retrospective science
 
Brain Talk: More effective conversations through clean language
Brain Talk: More effective conversations through clean languageBrain Talk: More effective conversations through clean language
Brain Talk: More effective conversations through clean language
 
Continuous Delivery: Responding to Change Faster Than Ever Before - SDEC14
Continuous Delivery: Responding to Change Faster Than Ever Before - SDEC14Continuous Delivery: Responding to Change Faster Than Ever Before - SDEC14
Continuous Delivery: Responding to Change Faster Than Ever Before - SDEC14
 
Continuous Delivery for Agile Teams
Continuous Delivery for Agile TeamsContinuous Delivery for Agile Teams
Continuous Delivery for Agile Teams
 
Exploring the magic behind dynamic finders: diving into ActiveRecord::Base.me...
Exploring the magic behind dynamic finders: diving into ActiveRecord::Base.me...Exploring the magic behind dynamic finders: diving into ActiveRecord::Base.me...
Exploring the magic behind dynamic finders: diving into ActiveRecord::Base.me...
 
Date Once
Date OnceDate Once
Date Once
 
Ruby For Java Programmers
Ruby For Java ProgrammersRuby For Java Programmers
Ruby For Java Programmers
 

Dernier

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationKnoldus Inc.
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...AliaaTarek5
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 

Dernier (20)

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Data governance with Unity Catalog Presentation
Data governance with Unity Catalog PresentationData governance with Unity Catalog Presentation
Data governance with Unity Catalog Presentation
 
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
(How to Program) Paul Deitel, Harvey Deitel-Java How to Program, Early Object...
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 

Inside Enumerable

  • 1.
  • 2.
  • 3.
  • 4. hash = { :a => 1, :b => 2} hash.collect do |key, value| value * 4 end [4,8] [4,8,12] [4,8,12] array = [1,2,3] array.collect do |value| value * 4 end range = 1..3 range.collect do |value| value * 4 end
  • 5. hash = { :a => 1, :b => 2} hash.collect do |key, value| value * 4 end array = [1,2,3] array.collect do |value| value * 4 end range = 1..3 range.collect do |value| value * 4 end module Enumerable def collect ... end end
  • 8. Mixins Cannot be instantiated Can be mixed in
  • 9.
  • 10. Enumerable requires each() [1,2,3].collect {|i| i*2} [2,4,6]
  • 11. Enumerable.collect class Foo include Enumerable def each yield 1 yield 2 yield 3 end end Foo.new.collect do |num| num * 2 end module Enumerable def collect array = [] each do |a| array << yield (a) end array end end
  • 12. Enumerable.collect module Enumerable def collect array = [] each do |a| array << yield (a) end array end end class Foo include Enumerable def each yield 1 yield 2 yield 3 end end Foo.new.collect do |num| num * 2 end
  • 13. Enumerable.collect module Enumerable def collect array = [] each do |a| array << yield (a) end array end end class Foo include Enumerable def each yield 1 yield 2 yield 3 end end Foo.new.collect do |num| num * 2 end
  • 14. Enumerable.collect class Foo include Enumerable def each yield 1 yield 2 yield 3 end end Foo.new.collect do |num| num * 2 end module Enumerable def collect array = [] each do |a| array << yield (a) end array end end
  • 15. Enumerable.collect module Enumerable def collect array = [] each do |a| array << yield (a) end array end end class Foo include Enumerable def each yield 1 yield 2 yield 3 end end Foo.new.collect do |num| num * 2 end
  • 16. Enumerable.collect class Foo include Enumerable def each yield 1 yield 2 yield 3 end end Foo.new.collect do |num| num * 2 end module Enumerable def collect array = [] each do |a| array << yield (a) end array end end Result [2,4,6]
  • 17.
  • 18. Enumerable methods all?, any?, collect, detect, each_cons, each_slice, each_with_index, entries, enum_cons, enum_slice, enum_with_index, find, find_all, grep, include?, inject, map, max, member?, min, partition, reject, select, sort, sort_by, to_a, to_set, zip
  • 19. any? [1,2,3,4].any? {|a| a > 2} Returns true if this block... ...returns true for any of these values
  • 20. all? [1,2,3,4].all? {|a| a > 2} Returns true if this block... ...returns true for ALL of these values
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26. Case equality case myvar when 1..50 # do something when 51 # do something when /^+$/ # do something end Within the range This exact number Matches this regular expression Different kind of equality as a convenience in case statements
  • 27. Case equality in grep [1,2,3].grep(1..50) [1,2,3].grep(51) [1,2,3].grep(/^+$/) Within the range This exact number Matches this regular expression
  • 28.
  • 29.