Posted: Mon Jan 08, 2007 6:57 pm Post subject: [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.
Sponsor Sponsor
ericfourfour
Posted: Tue Jan 09, 2007 11:17 pm Post subject: Re: [TYS] Properties
Does this pass?
Ruby:
Foo = Struct.new(:bar, :baz) class Foo
defto_s "#{bar} #{baz}" end
end