Sha256: a248c76c95cc6463881d122b661093917e2992f49b686c18d121300f1c5d2bb4
Contents?: true
Size: 565 Bytes
Versions: 6
Compression:
Stored size: 565 Bytes
Contents
class Fixnum # Allows #succ to take _n_ increments. # # 3.succ(2) #=> 5 # # CREDIT: Trans def succ(n=1) self + n end # Provides #pred as the opposite of #succ. # # 3.pred(2) #=> 1 # # CREDIT: Trans def pred(n=1) self - n end end class String alias_method :succ1, :succ # Allows #succ to take _n_ step increments. # # "abc".succ #=> "abd" # "abc".succ(4) #=> "abg" # "abc".succ(24) #=> "aca" # # CREDIT: Trans def succ(n=1) s = self n.times { s = s.succ1 } s end end
Version data entries
6 entries across 6 versions & 1 rubygems