V
vannuys
Hi Guys,
Is this default ruby behaviour or is this a bug? Based on the number
of call to Testappend::get_some_value, the string "-New Value" is
appended x number of times. If you first assign value = '' instead of
value = @text, the behaviour is different and the "-New Value" string
is appended only once.
version of ruby: ruby 1.8.6 (2007-03-13 patchlevel 0) [x86_64-linux]
Thanks.
Philippe
-----------------------------------------------------
module ATest
def ATest.main
t = TestAppend.new
puts t.get_some_value ==> Start of string-New Value
puts t.get_some_value ==> Start of string-New Value-New Value
puts t.get_some_value ==> Start of string-New Value-New Value-New
Value
end
class TestAppend
attr_accessor :text
def initialize(attributes = {})
@text = "Start of string"
end
def get_some_value
value = @text
value << '-New Value'
return value
end
end
end
ATest::main
Is this default ruby behaviour or is this a bug? Based on the number
of call to Testappend::get_some_value, the string "-New Value" is
appended x number of times. If you first assign value = '' instead of
value = @text, the behaviour is different and the "-New Value" string
is appended only once.
version of ruby: ruby 1.8.6 (2007-03-13 patchlevel 0) [x86_64-linux]
Thanks.
Philippe
-----------------------------------------------------
module ATest
def ATest.main
t = TestAppend.new
puts t.get_some_value ==> Start of string-New Value
puts t.get_some_value ==> Start of string-New Value-New Value
puts t.get_some_value ==> Start of string-New Value-New Value-New
Value
end
class TestAppend
attr_accessor :text
def initialize(attributes = {})
@text = "Start of string"
end
def get_some_value
value = @text
value << '-New Value'
return value
end
end
end
ATest::main