Hey,
I'm implementing a few things in Ruby and I was wondering how much error checking is appropriate (or, more precisely, how much error checking should be done by convention)?
For example, I'm implementing a method which swaps two elements in an array. The method is very simple:
def swap(a,b)
@array[a], @array[b] = @array[b], @array[a]
end
It's really simple, but is it ruby-ish to check whether the given indexes are valid, or is that an unnecessary overhead (bearing in mind I do not intend for the method to work with wrap-around values like -1)?