35 Commits

Author SHA1 Message Date
Yukihiro "Matz" Matsumoto 13bc858dff mrblib: use yield instead of block.call for iteration methods
Replace block.call(x) with yield x in core iteration methods to take
advantage of the new OP_BLKCALL optimization. This improves Integer#times
by 13% and Array#each by 7%.

Methods updated:
- Integer#times, Integer#upto, Integer#downto
- Array#each, Array#each_index

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-27 14:57:26 +09:00
Yukihiro "Matz" Matsumoto 6b2d0b3e0f numeric.rb: add parentheses to block.call
added parentheses to block.call where the return value is used.

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:07 +09:00
Yukihiro "Matz" Matsumoto ec1f9860b1 mrblib: add parentheses to method calls with used return values
added parentheses to all `to_enum` and `super` calls where the return
value is used (returned, assigned, or passed to another method). this
makes the code style consistent with the guideline that method calls
should use parentheses when their return values are consumed.

changes:
- return to_enum :symbol -> return to_enum(:symbol)
- return to_enum :symbol, arg -> return to_enum(:symbol, arg)
- super message, name -> super(message, name)

affected files: 10error.rb, array.rb, enum.rb, hash.rb, kernel.rb,
numeric.rb, range.rb

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-11 18:09:06 +09:00
Yukihiro "Matz" Matsumoto 07b803e28a docs: replace xml-style markup with markdown in comments
Replace XML-style markup tags in comments with markdown equivalents:
- <code>...</code> to `...` (inline code)
- <tt>...</tt> to `...` (teletype/monospace)
- <i>...</i> to *...* (italics/emphasis)
- +...+ to `...` (parameter/variable references)

Updated 80+ files across core source, headers, mrbgems, and libraries
to use consistent markdown formatting in documentation comments.
Handled edge cases including special characters like <=> operators.

Co-authored-by: Atlassian Rovo Dev
2025-08-14 10:52:49 +09:00
Yukihiro "Matz" Matsumoto e8bb03da40 numeric.rb (step): iterate over integers even if end is a float
It used to check all `start`, `end` and `step`. If either of them are
float number, `#step` iterated over float number. Now we don't check the
type of `end` argument.
2024-08-03 13:35:09 +09:00
Yukihiro "Matz" Matsumoto ecd2d8c11e wrap method arguments by parentheses as convention 2023-02-01 14:33:46 +09:00
Yukihiro "Matz" Matsumoto abec98c681 numeric.c: implement ceil, floor, round, truncate methods in C.
- ISO 15.2.8.3.14 Integer#ceil
- ISO 15.2.8.3.17 Integer#floor
- ISO 15.2.8.3.20 Integer#round
- ISO 15.2.8.3.26 Integer#truncate
2022-08-10 13:38:23 +09:00
Yukihiro "Matz" Matsumoto 4d249c28d9 Skip tests that use Float inside; ref #5421 2021-04-24 12:04:08 +09:00
Yukihiro "Matz" Matsumoto e55abd2390 Fix compiler errors from MRB_NO_FLOAT; #5185
Also added `no-float.rb` target in `build_config`.
2020-11-24 16:54:39 +09:00
Yukihiro "Matz" Matsumoto 2b188ed8a1 Reorganize Integer system.
- Integrate `Fixnum` and `Integer`
- Remove `Integral`
- `int / int -> int`
- Replace `mrb_fixnum()` to `mrb_int()`
- Replace `mrb_fixnum_value()` to `mrb_int_value()`.
- Use `mrb_integer_p()` instead of `mrb_fixnum_p()`
2020-10-12 18:19:54 +09:00
KOBAYASHI Shuji 32c2aa10c7 Fix Numeric#step to infinity; ref. #4555 2019-07-07 22:10:32 +09:00
KOBAYASHI Shuji 8969edf03b Avoid runtime evaluation for MRB_WITHOUT_FLOAT 2019-01-16 19:32:29 +09:00
KOBAYASHI Shuji de5da4b7f6 Fix coercing for first step counter in Numeric#step
Before:

  a=[]; 7.step(4, -3.0) { |c| a << c }; p a  #=> [7, 4.0]

After / Ruby:

  a=[]; 7.step(4, -3.0) { |c| a << c }; p a  #=> [7.0, 4.0]
2019-01-15 21:41:54 +09:00
Yukihiro "Matz" Matsumoto cca19532c5 Remove Kernel#class_defined? which is not available in CRuby; #3829 2019-01-03 11:34:35 +09:00
YAMAMOTO Masaya acdc2d1f24 Add MRB_WITHOUT_FLOAT 2017-10-11 17:58:11 +09:00
Christopher Aue 3359b86ec7 Improved speed of enumeration methods 2017-07-30 13:19:31 +02:00
Yukihiro "Matz" Matsumoto b23fb45f9c Integral#step without arg should loop forever as CRuby does. 2017-01-20 17:58:29 +09:00
Yukihiro "Matz" Matsumoto efebbbbf26 Implement Float shift methods in C 2016-11-23 09:45:50 +09:00
Yukihiro "Matz" Matsumoto 74696ffd96 Float << and >> should be more compatible to Fixnum 2015-09-02 22:29:01 +09:00
go.kikuta cb870de2b5 numeric.rb: refactor code (Avoid using {...} for multi-line blocks, Surrounding space missing in default value assignment) 2015-08-21 14:54:00 +09:00
Yukihiro "Matz" Matsumoto b05d736b49 update mrblib/*.rb files to conform (some of) Rubocop checks 2015-05-29 17:01:52 +09:00
TOMITA Masahiro bbab89e730 Fix: Numeric#step infinite loop. 2014-11-26 01:34:07 +09:00
Yukihiro "Matz" Matsumoto 653ddd6d3e downto, upto, step to return Enumerator 2014-04-03 20:19:54 +09:00
Yukihiro "Matz" Matsumoto 113ab60784 mruby-enumerator: move definitions in core_mod.rb to mrblib core 2014-03-14 02:41:22 +09:00
Tomoyuki Sahara 9686890ab3 Fix Float#divmod. 2014-03-04 10:51:36 +09:00
Yukihiro "Matz" Matsumoto 9eadd05f32 modify upto/downto for compatibility 2013-10-23 10:34:00 +09:00
Yukihiro "Matz" Matsumoto 2607970ed9 move some methods to make floats and integers compatible [mruby special] 2013-10-22 16:18:11 +09:00
Yukihiro "Matz" Matsumoto 620f8b2721 implement some Numeric methods in Ruby 2013-10-22 15:59:41 +09:00
Yukihiro "Matz" Matsumoto 3ae0616710 implement Integer#succ in Ruby 2013-10-21 07:42:50 +09:00
Masaki Muranaka cbe7a87c68 Move Integer.{floor,ceil,round,truncate} to mrblib/. For maintainability. 2013-03-31 23:04:45 +09:00
Yukihiro Matsumoto ef17231bd7 Integer#step added 2012-09-15 15:04:51 +09:00
Yukihiro Matsumoto 4de0a2afbf Numeric#{upto,downto}: limit may not be an integer 2012-09-15 14:48:31 +09:00
Daniel Bovensiepen b032acd6b6 Modify documentation of Numeric 2012-05-06 18:16:02 +08:00
Daniel Bovensiepen 42197ae0a6 Add some more documentation for Integer 2012-05-01 23:43:49 +08:00
mimaki e0d6430f63 add mruby sources 2012-04-20 09:39:03 +09:00