Last active
December 23, 2015 17:29
-
-
Save pjaspers/6669390 to your computer and use it in GitHub Desktop.
ruby-2.1.0-preview1 changes in code samples.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# def foo now returns a symbol instead of nil, allowing for something like this | |
class Thing | |
protected def some;end | |
protected def like; end | |
def it; end | |
protected def hot; end | |
end | |
Thing.new.protected_methods | |
=> [:some, :like, :hot] | |
# Refinements, example from [here](http://www.rubyinside.com/ruby-refinements-an-overview-of-a-new-proposed-ruby-feature-3978.html) | |
module TimeExtensions | |
refine Fixnum do | |
def minutes; self * 60; end | |
end | |
end | |
class MyApp | |
using TimeExtensions | |
def initialize | |
p 2.minutes | |
end | |
end | |
MyApp.new # => 120 | |
p 2.minutes # => NoMethodError | |
# F suffix will make `String` frozen. | |
"bla"f.gsub!("l", "k") | |
# RuntimeError: can't modify frozen String | |
# Complete list [here](https://github.com/ruby/ruby/blob/v2_1_0_preview1/NEWS) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"bla"f really looks like a syntax error to me