hellogoodbye hellogoodbye - 10 months ago 56
Ruby Question

ruby apply method to string interpolation

I want to convert a neg number to a pos in ruby so am using the abs method.

puts("You are #{playerGuess - num} away")

this is the current code but want to make the result from playerGuess - num always positive. how does one apply the abs method to this? if I do
#{playerGuess - num}
it just outputs the word


Like this:

puts("You are #{(playerGuess - num).abs} away")