So whats the SP equivalent of >= & <=?

define :decrease_volume do |i, n |
  if volume[i] - n  >  0 then # works
    volume[i] = volume[i] - n
  end
end

define :increase_volume  do |i, n |
  if volume[i] + n = < 10 then # doesn't work
    volume[i] = volume[i] + n
  end
end

Eli…

Hi @Eli,

try:

define :increase_volume  do |i, n |
  if volume[i] + n <= 10 
    volume[i] = volume[i] + n
  end
end

Or the more succinct:

define :increase_volume  do |i, n |
   volume[i] = volume[i] + n if volume[i] + n <= 10
end

However, be aware that using values not defined in the function such as the array volume is not recommended and certainly not thread safe (and therefore will produce non-deterministic behaviour. You are much better off using set and get, or passing volume as an argument to the function.

Thanks Sam…

One day I’ll rewrite my song framework to use set & get… honest.
Probably the day after it stops working…

Eli…