if(current_day == "Monday" || current_day == "Wednesday" || current_day == "Friday")
with if(["Monday", "Wednesday", "Friday"].include?(current_day))
I've done this before, and I don't think it's any less clear -- I wouldn't have thought of making a public announcement about it, though. I like it because it more closely aligns with the way you're probably thinking in this example: you're wondering if current_day is part of a certain set of days (the discount weekdays, apparently), not if it's equal to "Monday" or equal to "Tuesday", etc. I like the Javascript example with it's indexOf(..) >= 0 a lot less, but I guess people more used to JS idioms auto-translate this sequence to a set-contains operation.It's more sensible if the set of values is larger than just three; and in this instance, you have to wonder why the day isn't available as a numeric variable, but I think you can let it slide for a contrived example.
It's even more useful if you reference the same set more than once, because you can just define it once, and as a constant if your language of choice does that kind of thing. This would also let you make your code less wordy (but arguably more literal) without hiding logic in functions, e.g. his later example would be
if(discount_weekdays.include?(current_day) && current_date > 20)Both are correct, I am strictly referring to his rationale being it's too verbose.
if 5 in [1, 2, 5, 6, 8]:
pass case current_day when "Monday", "Wednesday", "Friday" then <do stuff> endHis choice to use [].include? is idiomatic ruby so I don't think it's being clever for clever's sake... although I've always kind of stumbled over that construct, I sort of wish there was an 'in' statement... if current_day in [x,y,z]. It would be easier to read (for me at least).
Your pseudocode is idiomatic Python code :)
Moreover, the memoise part is better handled with a decorator: it is a special behavior of the function and don't relate to its logic (its body).