mardi 18 août 2015

Convert positive integer to negative integer

  def negate_amount
    amount = model.amount.to_s
    ("-" + amount).to_i
  end

is there a better way to turn positive integer to negative?

The code above works, but is there a ruby or rails function for that? Without doing math operations?

Aucun commentaire:

Enregistrer un commentaire