Ignore:
Timestamp:
Jul 9, 2020, 8:51:43 AM (4 years ago)
Author:
coas-nagasima
Message:

mrubyを2.1.1に更新

Location:
EcnlProtoTool/trunk/mruby-2.1.1
Files:
1 edited
1 moved

Legend:

Unmodified
Added
Removed
  • EcnlProtoTool/trunk/mruby-2.1.1/mrblib/numeric.rb

    r331 r439  
    4646  # ISO 15.2.8.3.15
    4747  def downto(num, &block)
    48     return to_enum(:downto, num) unless block_given?
     48    return to_enum(:downto, num) unless block
    4949
    5050    i = self.to_i
     
    7171  # ISO 15.2.8.3.22
    7272  def times &block
    73     return to_enum :times unless block_given?
     73    return to_enum :times unless block
    7474
    7575    i = 0
     
    8787  # ISO 15.2.8.3.27
    8888  def upto(num, &block)
    89     return to_enum(:upto, num) unless block_given?
     89    return to_enum(:upto, num) unless block
    9090
    9191    i = self.to_i
     
    103103  def step(num=nil, step=1, &block)
    104104    raise ArgumentError, "step can't be 0" if step == 0
    105     return to_enum(:step, num, step) unless block_given?
     105    return to_enum(:step, num, step) unless block
    106106
    107     i = if num.kind_of? Float then self.to_f else self end
    108     if num == nil
     107    i = __coerce_step_counter(num, step)
     108    if num == self || step.infinite?
     109      block.call(i) if step > 0 && i <= (num||i) || step < 0 && i >= (num||-i)
     110    elsif num == nil
    109111      while true
    110112        block.call(i)
    111         i+=step
     113        i += step
    112114      end
    113       return self
    114     end
    115     if step > 0
     115    elsif step > 0
    116116      while i <= num
    117117        block.call(i)
     
    162162  alias truncate floor
    163163end
    164 
    165 ##
    166 # Float
    167 #
    168 # ISO 15.2.9
    169 class Float
    170   # mruby special - since mruby integers may be upgraded to floats,
    171   # floats should be compatible to integers.
    172   include Integral
    173 end
Note: See TracChangeset for help on using the changeset viewer.