Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
The Cool,
     Confusing &
      Downright
     Frustrating
Some nifty things for the beginning rubyist




              ...
The Cool, Confusing &
Downright frustrating
The Cool, Confusing &
Downright frustrating
 Who’s this chick and why is she blabbing
 about Ruby?
The Cool, Confusing &
Downright frustrating
 Who’s this chick and why is she blabbing
 about Ruby?

 The Cool: Mixins
The Cool, Confusing &
Downright frustrating
 Who’s this chick and why is she blabbing
 about Ruby?

 The Cool: Mixins

 Th...
The Cool, Confusing &
Downright frustrating
 Who’s this chick and why is she blabbing
 about Ruby?

 The Cool: Mixins

 Th...
The Cool, Confusing &
Downright frustrating
 Who’s this chick and why is she blabbing
 about Ruby?

 The Cool: Mixins

 Th...
Who Am I?
Who Am I?

Java Background
Who Am I?

Java Background

Currently working with Ruby/RoR
Who Am I?

Java Background

Currently working with Ruby/RoR

Wife, mom, knitting enthusiast, karaoke queen
- Ok... maybe n...
The Cool
The Cool

Mixins
The Cool

Mixins

 Ruby only supports single inheritance
The Cool

Mixins

 Ruby only supports single inheritance

 A class mixed with a module
The Cool

Mixins

 Ruby only supports single inheritance

 A class mixed with a module

 Provide functionality when and wh...
Mixins
Class vs. Module
Mixins
Class vs. Module
Mixins
Class vs. Module
Mixins
Mixins

Include - Mix in at the instance level
Mixins

Include - Mix in at the instance level

Extend -
Mixins

Include - Mix in at the instance level

Extend -

  Mix in at the class level
Mixins

Include - Mix in at the instance level

Extend -

  Mix in at the class level

  Provide functionality at runtime
The Confusing
The Confusing


Blocks
The Confusing


Blocks

Procs
The Confusing


Blocks

Procs

lambda
Blocks
Blocks


do .. end or {}
Blocks


do .. end or {}

Are not method arguments
Blocks


do .. end or {}

Are not method arguments

Can take their own parameters
block vs. Proc
block vs. Proc


A block is not an object
block vs. Proc


A block is not an object

blocks can be converted into Procs
Procs
Procs


Can be created at runtime
Procs


Can be created at runtime

Passed as arguments to other functions
Procs


Can be created at runtime

Passed as arguments to other functions

Returned as the value of other functions
Proc vs. lambda
Proc vs. lambda


lambdas check the number of arguments
Proc vs. lambda


lambdas check the number of arguments

lambdas have diminutive returns
The Downright
 Frustrating
The Downright
     Frustrating

Avoid 1-offs by using the correct range
notation
The Downright
     Frustrating

Avoid 1-offs by using the correct range
notation

All things are not created equal
Review
Review


Mixins
Review


Mixins

blocks, Proc, lambda
Review


Mixins

blocks, Proc, lambda

General frustrations
Questions?
The End


Twitter: @jendavis

Blog: grandioseideas.com

Email: jdavis@medsagetechnologies.com
Coolness
Coolness
Coolness
Upcoming SlideShare
Loading in …5
×

Coolness

4,360 views

Published on

This was a talk I did for the Pittsburgh Ruby Brigade in February 2010. The slides are quite bare but there were a lot of live code examples and discussion.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Coolness

  1. 1. The Cool, Confusing & Downright Frustrating Some nifty things for the beginning rubyist By: Jennifer Davis
  2. 2. The Cool, Confusing & Downright frustrating
  3. 3. The Cool, Confusing & Downright frustrating Who’s this chick and why is she blabbing about Ruby?
  4. 4. The Cool, Confusing & Downright frustrating Who’s this chick and why is she blabbing about Ruby? The Cool: Mixins
  5. 5. The Cool, Confusing & Downright frustrating Who’s this chick and why is she blabbing about Ruby? The Cool: Mixins The Confusing: Blocks, Procs, lambda
  6. 6. The Cool, Confusing & Downright frustrating Who’s this chick and why is she blabbing about Ruby? The Cool: Mixins The Confusing: Blocks, Procs, lambda The Downright Frustrating
  7. 7. The Cool, Confusing & Downright frustrating Who’s this chick and why is she blabbing about Ruby? The Cool: Mixins The Confusing: Blocks, Procs, lambda The Downright Frustrating Review
  8. 8. Who Am I?
  9. 9. Who Am I? Java Background
  10. 10. Who Am I? Java Background Currently working with Ruby/RoR
  11. 11. Who Am I? Java Background Currently working with Ruby/RoR Wife, mom, knitting enthusiast, karaoke queen - Ok... maybe not, but I try
  12. 12. The Cool
  13. 13. The Cool Mixins
  14. 14. The Cool Mixins Ruby only supports single inheritance
  15. 15. The Cool Mixins Ruby only supports single inheritance A class mixed with a module
  16. 16. The Cool Mixins Ruby only supports single inheritance A class mixed with a module Provide functionality when and where you need it
  17. 17. Mixins Class vs. Module
  18. 18. Mixins Class vs. Module
  19. 19. Mixins Class vs. Module
  20. 20. Mixins
  21. 21. Mixins Include - Mix in at the instance level
  22. 22. Mixins Include - Mix in at the instance level Extend -
  23. 23. Mixins Include - Mix in at the instance level Extend - Mix in at the class level
  24. 24. Mixins Include - Mix in at the instance level Extend - Mix in at the class level Provide functionality at runtime
  25. 25. The Confusing
  26. 26. The Confusing Blocks
  27. 27. The Confusing Blocks Procs
  28. 28. The Confusing Blocks Procs lambda
  29. 29. Blocks
  30. 30. Blocks do .. end or {}
  31. 31. Blocks do .. end or {} Are not method arguments
  32. 32. Blocks do .. end or {} Are not method arguments Can take their own parameters
  33. 33. block vs. Proc
  34. 34. block vs. Proc A block is not an object
  35. 35. block vs. Proc A block is not an object blocks can be converted into Procs
  36. 36. Procs
  37. 37. Procs Can be created at runtime
  38. 38. Procs Can be created at runtime Passed as arguments to other functions
  39. 39. Procs Can be created at runtime Passed as arguments to other functions Returned as the value of other functions
  40. 40. Proc vs. lambda
  41. 41. Proc vs. lambda lambdas check the number of arguments
  42. 42. Proc vs. lambda lambdas check the number of arguments lambdas have diminutive returns
  43. 43. The Downright Frustrating
  44. 44. The Downright Frustrating Avoid 1-offs by using the correct range notation
  45. 45. The Downright Frustrating Avoid 1-offs by using the correct range notation All things are not created equal
  46. 46. Review
  47. 47. Review Mixins
  48. 48. Review Mixins blocks, Proc, lambda
  49. 49. Review Mixins blocks, Proc, lambda General frustrations
  50. 50. Questions?
  51. 51. The End Twitter: @jendavis Blog: grandioseideas.com Email: jdavis@medsagetechnologies.com

×