Project

General

Profile

ActionsLike0

Feature #3591

closed

Adding Numeric#divisor? (Have working implementation)

Added by duckinator (Marie Markwell) over 14 years ago. Updated about 2 years ago.

Status:
Rejected
Target version:
[ruby-core:31385]

Description

=begin
On the 'duckinator' branch of my fork of ruby on github, I have added Numeric#divisor?:
num.divisor?(other)
is the same as:
(num % other == 0)

Example usage:
4.divisor?(2) #=> true
1.divisor?(2) #=> false
2.4.divisor?(1.2) #=> true
2.4.divisor?(1.3) #=> false
126.divisor?(9) #=> true

I think this would be a very nice feature to add, and would make code using the old (num % other == 0) method much cleaner and easier to understand.

There is a unified diff of it: http://gist.github.com/raw/484144/07b1a6e696cd9301e658ccbc8f90dfcd4d4ef3f1/Numeric_divisor.patch

The original commits can be seen here:
http://github.com/RockerMONO/ruby/commit/f7959f964cb0bf38418904ccb5643db6b689d29c -- First attempt, only worked with Integers
http://github.com/RockerMONO/ruby/commit/12376a6bb1c3ffbd4b470850dd758e2dcd783dda -- Second attempt, should work with anything derived from Numeric that can be used as (num % other == 0)
=end

#8

Updated by akr (Akira Tanaka) almost 14 years ago

  • Project changed from 8 to Ruby

Updated by mame (Yusuke Endoh) about 13 years ago

  • Description updated (diff)
  • Status changed from Open to Assigned
  • Assignee set to mrkn (Kenta Murata)

Updated by marcandre (Marc-Andre Lafortune) over 12 years ago

  • Category set to core
  • Assignee changed from mrkn (Kenta Murata) to matz (Yukihiro Matsumoto)

Updated by mame (Yusuke Endoh) over 12 years ago

  • Target version set to 2.6

Updated by matz (Yukihiro Matsumoto) over 7 years ago

  • Status changed from Assigned to Rejected
ActionsLike0

Also available in: Atom PDF