Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[PATCH] Let Integer#multiple_of? accept zero as argument

#2982

Currently Integer#multiple_of? delegates to %, and so raises a division by zero exception if the argument is zero.

But that case is of course well-defined: no integer is multiple of zero except zero. This little patch adds that.

Reported by Xavier Noria · August 1st, 2009 @ 02:45 AM

State: committed
Milestone: none
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. Peter Wagenet
  2. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from activesupport, integer, multiple_of to activesupport, bugmash, integer, multiple_of

    September 25th, 2009 @ 01:00 PM

  3. Robert Rouse
    Robert Rouse

    The current patch does not apply on the 2.3 stable branch. I have reformatted the patch for the branch.

    Attached is the patch.

    September 26th, 2009 @ 03:06 AM

  4. Robert Rouse
    Robert Rouse

    I should say the original patch would apply to master.

    September 26th, 2009 @ 03:16 AM

  5. Elad Meidar
    Elad Meidar

    +1 verified and both patches apply cleanly.

    September 26th, 2009 @ 04:18 AM

  6. Pat Allan
    Pat Allan
    • Tag changed from activesupport, bugmash, integer, multiple_of to activesupport, bugmash, bugmash-review, integer, multiple_of

    Just tested on 2.3 and master, all good. +1 Verified.

    September 26th, 2009 @ 04:56 PM

  7. Josh Sharpe
    Josh Sharpe
    • Title changed from Let Integer#multiple_of? accept zero as argument to [PATCH] Let Integer#multiple_of? accept zero as argument

    +1 both patches work

    September 26th, 2009 @ 06:19 PM

  8. sr.iniv.t
    sr.iniv.t

    +1 verified.

    Xavier's patch applies on 2-3-stable and all tests pass. Robert's patch didn't apply for me for whatever reason, don't know what i was doing wrong.

    September 26th, 2009 @ 07:26 PM

  9. Robert Rouse
    Robert Rouse

    sr.iniv.t:

    You probably didn't have the 2-3-stable branch checked out when you applied the patch I attached. The original patch will apply on master. Mine applies on 2-3-stable. They need to be different because master adds methods to the Integer class directly. 2-3-stable uses a module.

    September 26th, 2009 @ 09:15 PM

  10. John Pignata
    John Pignata

    +1 verified - both patches apply

    September 26th, 2009 @ 09:16 PM

  11. sr.iniv.t
    sr.iniv.t

    Robert:

    Errr, sorry about the mix up. I was indeed trying Xavier's patch on master. I applied your patch to 2-3-stable and the patch applies fine. :-)

    September 26th, 2009 @ 09:21 PM

  12. Blue Box Chris
  13. qmx
    qmx

    +1 patch applies cleanly

    September 27th, 2009 @ 04:06 AM

  14. Matías Flores
    Matías Flores

    verified the issue and patch applied cleanly

    September 27th, 2009 @ 05:25 AM

  15. Kieran P
    Kieran P

    +1 verified patches apply cleanly.

    September 27th, 2009 @ 07:13 AM

  16. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from activesupport, bugmash, bugmash-review, integer, multiple_of to activesupport, bugmash-review, integer, multiple_of

    September 27th, 2009 @ 11:46 AM

  17. Xavier Noria
    Xavier Noria
    • Assigned user set to Jeremy Kemper

    Updates the patch so that it applies after the recent 1.8.6 cleanup in AS. New file is let_multiple_of_accept_zero_2.diff.

    November 15th, 2009 @ 12:26 AM

  18. Repository
  19. Rizwan Reza
    Rizwan Reza
    • Tag changed from activesupport, bugmash-review, integer, multiple_of to activesupport, integer, multiple_of

    May 15th, 2010 @ 06:40 PM