Skip to content

Instantly share code, notes, and snippets.

@aviflombaum
Created January 12, 2011 22:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aviflombaum/777013 to your computer and use it in GitHub Desktop.
Save aviflombaum/777013 to your computer and use it in GitHub Desktop.
igrigorik collection of things about ruby 1.9 that make him standup
#ruby19 added ObjectSpace.count_objects method which returns a hash of types+counts of objects in current process #standup
#ruby19 allows default parameters in procs & lambdas! ex: f = -> a,b=1,*c { p [a,b,c] }; f.call(1); f.(1,2); f[1,2,3] #standup
#ruby19 no longer supports .each on a string! instead, use: .chars, .bytes, .lines #standup
#ruby19 supports 3 ways to call a proc! ex: f =->n {[:hello, n]}; f[:ruby]; f.call(:ruby); f.(:ruby) #standup
#ruby19 hashes preserve the insertion order of elements! for the curious: http://bit.ly/e0oEun #standup
#ruby19 supports new "stabby proc" syntax! ex: lambda {|a,b| ...} is same as: -> a,b {...} #standup
#ruby19 supports new & more compact hash syntax for symbol keys! ex: {a:1, b:2} - http://bit.ly/fCglqo #standup
#ruby19 allows matching regular expressions against a symbol! ex: :ruby_symbol.match /symbol/ => 5 #standup
#ruby19 allows default arguments at the beginning of a method! ex: def do(a=1, b); p [a,b]; end; do(2) # => [1, 2] #standup
#ruby19 supports named captures in regular expressions! ex: "hello 2011!".match(/(?<year>\d+)/)[:year] # => 2011 #standup
#ruby19 allows splat argument anywhere in a method's parameter list! ex: def a(a,*b,c); end #standup
#standup #ruby19: Enumerable.reduce == Enumerable.inject, ex: [1,2,3].reduce(:+)
#ruby19 added each_with_object to Enumerable! ex: evens = (1..10).each_with_object([]) {|i, a| a << i*2 } #standup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment