The code below should display the longest word in the input string. The second line (1) works as expected while the third one (2) doesn’t. The only difference is the class of the memo_obj: array (1) and string (2). Who can explain?
Well, you are mutating the array at the 2nd line (which doesn’t change the object_id), but on the 3rd line, you are reassigning the string. So the string no longer refers to the original object in the reduce.