Hi I have a strange situation here:
# Is there a semantic difference between these 2 in ruby?
class MyClass < ClassThatExtendsActiveRecordBase
...
# code snippet A:
def image_width(size); self.image.width(size); end
# vs code snippet B
def image_width(size)
self.image.width(size)
end
end
I have a situation where code snippet A didn’t appear to be recognised as a function
but when I modify A by substituting semicolons with return chars to produce B the methods are recognised (this is ruby 1.8.7)
Is anyone able to help me understand what is happening that this occurs?
There shouldn’t be. And there isn’t, at least with the versions I have tested:
Since the code example you posted is incomplete and doesn’t even parse correctly, I used a slightly modified version to test:
You wrote
What do you mean by that? There is no such thing as a function Ruby, so the fact that functions don’t work shouldn’t really be surprising.
Also, what do you mean by “recognised”? This word has a very specific meaning in programming, but you don’t appear to be using it with that meaning.
And lastly, what does it mean that it “appears” to not work? Does it or doesn’t it work?
Could you provide a complete and minimal testcase that exhibits the behavior you are seeing? Also, please describe:
At the moment, it looks like a very subtle bug in your specific installation of Ruby.