Find the last element of a list
Your input might be a String or an Array. Both of these support the :index method, so foo[-1] will give the last character of a string or the last element of an array. But if you test for it being an array, the solution won't work for strings when it otherwise would.
I don't think there's anything wrong with using ternary operators in ruby, as long as all three 'elements' are fairly short. More concise code is easier to read. See the Ruby Style Guide at https://github.com/bbatsov/ruby-style-guide#ternary-operator.