add Integer#pred (#5)

Submitted by: Robert Dober

This revision by: Robert Dober

Date: Mon Jan 15 11:47:08 -0500 2007

View earlier revisions

ABSTRACT

The Integer class contains the #succ method returning (self + 1). I feel that it would be good to have the symetric method #pred too.

PROBLEM

A user knowing about Integer#succ might want to use Integer#pred.

PROPOSAL

Add the Integer#pred method that shall return (self – 1).

ANALYSIS

This change should be trivial and does not present any problem with backwards compatibility.

IMPLEMENTATION

class Integer

def pred
self - 1
end

end

Comments


Return to top

Copyright © 2006, Ruby Power and Light, LLC