I am trying to create a condition statement in Ruby. If my array of various numbers is empty or nil, it should return an empty array otherwise it should sort the numbers. This is what I have so far.
num == nil || num.empty? ? return num : num.sort!
...where num is my array. However I'm getting the following error:
syntax error, unexpected tIDENTIFIER, expecting ':'
I get this error if num is an array of numbers or nil. I'm not sure why this isn't working. Any thoughts?