Reputation: 4516
Does ruby on rails have an equivalent to ++value.
In c there's a ++x and a x++
They are not the same operation (strictly speaking).. Does rails have something simular
c++ code
int x = 0;
if(x++) cout << "value is not zero when compared"
else cout << "value still zero when compared"
//prints "value still zero when compared"
x = 0;
if(++x) cout << "value is not zero when compared"
else cout << "value is still zero when compared"
//prints "value is not zero when compared"
The ++x is a faster operation (small but faster), but that's not why I want it.. I want to print and add a value in the same line.. But I want to print out the value before the addition.
ruby code
#print out the count of products processed, the current id, and the current name
p "#{recCount++}:#{product.id} #{product.name}";
Upvotes: 2
Views: 85