G
George
This comes up every now and again, and lots of frameworks implement their own versions. I'm thinking
of submitting an RCR for something functionally equivalent to the following to be incorporated into
the base library:
class String
def starts?(aString)
index(aString) == 0
end
def ends?(aString)
rindex(aString) == length - aString.length
end
end
Of course, the real implementation would have much better performance. The advantage of including
something like this is that these common functions can be made both high-performance and readable.
Comments?
of submitting an RCR for something functionally equivalent to the following to be incorporated into
the base library:
class String
def starts?(aString)
index(aString) == 0
end
def ends?(aString)
rindex(aString) == length - aString.length
end
end
Of course, the real implementation would have much better performance. The advantage of including
something like this is that these common functions can be made both high-performance and readable.
Comments?