There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
That code can be shortened and still retain readability. Look at this style guide, and you can see it should be shortened toThe line breaks and () are not absolutely necessary, but may make it easier to read.Nazar Buko wrote: . . .
. . .
I have already hinted at that.Nazar Buko wrote: . . . How would I set up my set method so that, say the first time the method is called, it stores whatever char was provided in the parameter is the first letter of the combination, and the second time the . . .
When I was little, at school, we did exactly that. We could buy bicycle combination locks which were so poorly‑made, we could feel when one number of the combination was correct. At the age of ten, I could undo such a lock in about 30″fred rosenberger wrote: . . . On a real lock, you don't enter one number, see if it opens, enter the next number, see if it opens, enter the third, and see if it opens. . . .
Campbell Ritchie wrote:I think you will have to query that. You would have to change it to myLock.set('C', 'A', 'K'); or similar.
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |