koan_01_2.rb 452 B

12345678910111213141516171819
  1. # Next, the koan calls:
  2. # SomeClass.a = value
  3. # This appears to be a simple assignment statement, but is in fact a method call.
  4. # In Java, the practice for setting the value on an object is to call a method with
  5. # a name like 'set_field'. In .NET, you can use "properties". In Ruby, it's just
  6. # another method with assignment symantics.
  7. class SomeClass
  8. def self.attribute
  9. end
  10. def a?
  11. false
  12. end
  13. def a=(value)
  14. @val = value
  15. end
  16. end