Skip to content

Instantly share code, notes, and snippets.

@YanhaoYang
Created October 15, 2013 02:43
Show Gist options
  • Save YanhaoYang/6985729 to your computer and use it in GitHub Desktop.
Save YanhaoYang/6985729 to your computer and use it in GitHub Desktop.
Differences between Ruby 1.8 and 1.9

Date.parse

1.8.7: parse(str='-4712-01-01', comp=false, sg=ITALY)
1.9.3: parse(string='-4712-01-01T00:00:00+00:00'[, comp=true[, start=ITALY]])

Note: the default values of comp are different.

Enumerator#next

1.8.7:
>> enum = (1..3).to_enum
=> #<Enumerable::Enumerator:0x7f887c1006d8>
>> enum.next
=> 1
>> enum.next
=> 2
>> enum.next
=> 3
>> enum.next
StopIteration: iteration reached at end
>> enum.next
=> 1

1.9.3:
irb(main):002:0> enum.next
=> 1
irb(main):003:0> enum.next
=> 2
irb(main):004:0> enum.next
=> 3
irb(main):005:0> enum.next
StopIteration: iteration reached an end
irb(main):006:0> enum.next
StopIteration: iteration reached an end
irb(main):007:0> enum.next
StopIteration: iteration reached an end

Note: in Ruby 1.8, Enumerator will rewind automatially after reaching the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment