如果数组中有一组数字,你怎么能将它们反转,使正数为负数,负数为正数.
我已经尝试了以下,但似乎没有工作.
def invert(list) list.each {|x| x * (-1)} end
ruby numeric
numeric ×1
ruby ×1