J
Just Another Victim of the Ambient Morality
I've been having a lot of fun writing iTunes scripts with Ruby through
COM and have encountered behaviour I don't understand (what else is new).
The following code works just as you would expect:
iTunes = WIN32OLE.new('iTunes.Application')
iTunes.PlayerPosition = 50
iTunes.Play
...it starts playing the current song from position 50. However, you'd
think the following code would do exactly the same thing:
iTunes = WIN32OLE.new('iTunes.Application')
temp = iTunes.PlayerPosition
temp = 50
iTunes.Play
Okay, there are many languages where this would totally not do the same
thing but I thought that all variables in Ruby were references. So, the
assignment to temp should have made it refer to the same object that
iTunes.PlayerPosition returned.
So, what is going on? Why doesn't the second block of code work? Does
it have something to do with WIN32OLE or do I just have no idea how Ruby
works?
Thank you!
COM and have encountered behaviour I don't understand (what else is new).
The following code works just as you would expect:
iTunes = WIN32OLE.new('iTunes.Application')
iTunes.PlayerPosition = 50
iTunes.Play
...it starts playing the current song from position 50. However, you'd
think the following code would do exactly the same thing:
iTunes = WIN32OLE.new('iTunes.Application')
temp = iTunes.PlayerPosition
temp = 50
iTunes.Play
Okay, there are many languages where this would totally not do the same
thing but I thought that all variables in Ruby were references. So, the
assignment to temp should have made it refer to the same object that
iTunes.PlayerPosition returned.
So, what is going on? Why doesn't the second block of code work? Does
it have something to do with WIN32OLE or do I just have no idea how Ruby
works?
Thank you!