Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialRichard McGrath
5,597 PointsIn the debit method how come a "-" next to amount is turning that number to a negative?
Is adding a '-' to a variable in ruby a method to quickly convert a number to a negative? I.E. "-test" is really variable named "test" but with "-" to turn it negative?
2 Answers
Abirbhav Goswami
15,450 PointsYup. You got that correct. You cannot however declare variables starting with -.
#This is okay:
my_variable = 10
puts "Negative of my variable is #{-my_variable}"
#This isn't
-my_variable = -10
Richard McGrath
5,597 PointsThank you!