Which of these statements evaluates to the largest value?
9 Comments
Time DescendingStreak started, sanity optional. Matlab's apostrophe is a double agent (transpose or string?), so even lexers have to track whether the previous token was a value. One linter's notes say a quote after whitespace always starts a string, so that space in [''' '' '''] is the tiebreaker.
One would think that given my last name, I should be an expert in apostrification. (Is that a word? Surprsingly, it does appear to be a word.) And so you would think the answer was obvious to me, but it did take some thought.
Actually, it is not difficult, as long as you appreciate the rules of doubled apostrophes and character catenation. Just take your time and count. For me, I took each one, predicted the expected length, then verified my expectation.
Cute quiz question though.
char(nthroot(sum('Ouch!'),4)*17-8)
Character and String arrays are among the most difficult things in MATLAB for me. By the way, the square brackets are decorative or deceptive; with or without them, option E generates a variable of type char of length 5. Thank you for such an instructive quiz and an explanation.
I can tell which are single quotes. And, I can tell which are two single quotes OR double quotes. Other than that, I have to zoom way in to count...
I do these sorts of character array manipulations quite a bit (to construct input for SQL commands), and still got it wrong.
MATLAB having both character arrays and string arrays can add to the confusion! (I had to paste these into the editor to be certain whether any of the symbols were actually double-quotes.)
Sign in to participate