Whoops, that's what I get for copy-pasting into the wrong segment. You
are correct, Rob.

~ jf
--
John Feminella
Principal Consultant, BitsBuilder
LI: http://www.linkedin.com/in/johnxf
SO: http://stackoverflow.com/users/75170/



On Fri, Feb 18, 2011 at 10:29, Rob Biedenharn
<Rob / agileconsultingllc.com> wrote:
> On Feb 18, 2011, at 7:57 AM, John Feminella wrote:
>
>> Is it an "undefined method '+' on NilClass"? If so, you forgot to
>> assign a value to @plays before incrementing it. You might try
>> something like this instead:
>>
>> def plays
>> @plays ||= 0
>> end
>>
>> def plays=(v)
>> @plays = self.plays + 1
>> end
>>
>> ~ jf
>> --
>> John Feminella
>> Principal Consultant, BitsBuilder
>> LI: http://www.linkedin.com/in/johnxf
>> SO: http://stackoverflow.com/users/75170/
>
> I think you'd want:
>
> def plays=(v)
> @plays = v
> end
>
> In your original:
>
> plays = 5
> puts plays
> 1 # <== ???
>
> I can't imagine that's what the OP wants to see.
>
>
>
>>
>>
>>
>> On Thu, Feb 17, 2011 at 23:04, Sam Duncan <sduncan / wetafx.co.nz> wrote:
>>>
>>> What is the content of @plays?
>>>
>>> Sam
>>>
>>>
>>> On 18/02/11 17:01, Danny L. wrote:
>>>>
>>>> hey guys the following line of code is producing a "undefined method
>>>> `+':
>>>>
>>>> @plays += 1
>>>>
>>>>
>>>> cheers,
>>>>
>>>> Danny
>>>>
>>>>
>>>
>>>
>>
>
> Rob Biedenharn
> Rob / AgileConsultingLLC.com   http://AgileConsultingLLC.com/
> rab / GaslightSoftware.com    http://GaslightSoftware.com/
>
>
>