summaryrefslogtreecommitdiffhomepage
path: root/mrblib/range.rb
diff options
context:
space:
mode:
authorYukihiro "Matz" Matsumoto <[email protected]>2015-08-22 21:19:34 +0900
committerYukihiro "Matz" Matsumoto <[email protected]>2015-08-22 21:19:34 +0900
commitfd2f2f28debdbce8c08bd91305ecf8073817dc47 (patch)
tree9c5318614b0971f3be01dcc361b351434c2d5213 /mrblib/range.rb
parent71f2975a5ba93197fac6a08f21d84bc87e31c6ae (diff)
parent85f0dd7da0fe41310883d9a65156c429135590f5 (diff)
downloadmruby-fd2f2f28debdbce8c08bd91305ecf8073817dc47.tar.gz
mruby-fd2f2f28debdbce8c08bd91305ecf8073817dc47.zip
Merge pull request #2922 from gkta/refactor-mrubygem-code
Refactor mrubygem code (range.rb, numeric.rb, string.rb, array.rb, enum.rb)
Diffstat (limited to 'mrblib/range.rb')
-rw-r--r--mrblib/range.rb12
1 files changed, 3 insertions, 9 deletions
diff --git a/mrblib/range.rb b/mrblib/range.rb
index 64fa0cb6c..5e5fd9bdc 100644
--- a/mrblib/range.rb
+++ b/mrblib/range.rb
@@ -26,9 +26,7 @@ class Range
return self
end
- unless val.respond_to? :succ
- raise TypeError, "can't iterate"
- end
+ raise TypeError, "can't iterate" unless val.respond_to? :succ
return self if (val <=> last) > 0
@@ -37,18 +35,14 @@ class Range
val = val.succ
end
- if not exclude_end? and (val <=> last) == 0
- block.call(val)
- end
+ block.call(val) if !exclude_end? && (val <=> last) == 0
self
end
# redefine #hash 15.3.1.3.15
def hash
h = first.hash ^ last.hash
- if self.exclude_end?
- h += 1
- end
+ h += 1 if self.exclude_end?
h
end
end