
-----------------------------------
wtd
Mon Jan 08, 2007 6:57 pm

[TYS] Properties
-----------------------------------
Create a class Foo, with instance variables "bar" and "baz" which are both readable and writable.  The class should also have a method to_s which returns the two variables stringified, joined together separated by a space.

You may not use attr_*, "def" may occur at most twice, and the word "eval" may not occur in your code.  You may not use "require" in your code either.

-----------------------------------
ericfourfour
Tue Jan 09, 2007 11:17 pm

Re: [TYS] Properties
-----------------------------------
Does this pass?
Foo = Struct.new(:bar, :baz)
class Foo
  def to_s
    "#{bar} #{baz}"
  end
end

foo = Foo.new
foo.bar = "Hello"
foo.baz = "World"
puts foo
I added a bit at the end.
