diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-05-13 16:07:09 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2021-05-13 16:07:09 +0900 |
| commit | 5c7aa4f29934a8dc6534662d3e4c3b30c7f7ee5a (patch) | |
| tree | d07672c6aa6326cfd902247bf11f164ada91ca39 /mrblib | |
| parent | 2597e5192ff954bb54598dd87690a956876ca404 (diff) | |
| download | mruby-5c7aa4f29934a8dc6534662d3e4c3b30c7f7ee5a.tar.gz mruby-5c7aa4f29934a8dc6534662d3e4c3b30c7f7ee5a.zip | |
Simplify module inclusion for `Array`, `Hash` and `Range`.
Diffstat (limited to 'mrblib')
| -rw-r--r-- | mrblib/array.rb | 13 | ||||
| -rw-r--r-- | mrblib/hash.rb | 14 | ||||
| -rw-r--r-- | mrblib/range.rb | 13 |
3 files changed, 16 insertions, 24 deletions
diff --git a/mrblib/array.rb b/mrblib/array.rb index f74da332c..6b4f74b96 100644 --- a/mrblib/array.rb +++ b/mrblib/array.rb @@ -4,7 +4,6 @@ # # ISO 15.2.12 class Array - ## # Calls the given block for each element of +self+ # and pass the respective element. @@ -193,13 +192,6 @@ class Array return block.call if ret.nil? && block ret end -end - -## -# Array is enumerable -class Array - # ISO 15.2.12.3 - include Enumerable ## # Sort all elements and replace +self+ with these @@ -277,4 +269,9 @@ class Array self end alias entries to_a + + ## + # Array is enumerable + # ISO 15.2.12.3 + include Enumerable end diff --git a/mrblib/hash.rb b/mrblib/hash.rb index 085536c6c..ac70f4c70 100644 --- a/mrblib/hash.rb +++ b/mrblib/hash.rb @@ -4,6 +4,12 @@ # ISO 15.2.13 class Hash ## + # Hash is enumerable + # + # ISO 15.2.13.3 + include Enumerable + + ## # Equality---Two hashes are equal if they each contain the same number # of keys and if each key-value pair is equal to (according to # <code>Object#==</code>) the corresponding elements in the other @@ -297,11 +303,3 @@ class Hash h end end - -## -# Hash is enumerable -# -# ISO 15.2.13.3 -class Hash - include Enumerable -end diff --git a/mrblib/range.rb b/mrblib/range.rb index 087428c0d..fb217f771 100644 --- a/mrblib/range.rb +++ b/mrblib/range.rb @@ -3,6 +3,11 @@ # # ISO 15.2.14 class Range + ## + # Range is enumerable + # + # ISO 15.2.14.3 + include Enumerable ## # Calls the given block for each element of +self+ @@ -80,11 +85,3 @@ class Range end alias entries to_a end - -## -# Range is enumerable -# -# ISO 15.2.14.3 -class Range - include Enumerable -end |
