From: brabuhr@... Date: 2009-08-05T00:22:09+09:00 Subject: Re: Java code to Ruby code?? On Tue, Aug 4, 2009 at 4:11 AM, Brian Candler wrote: > Kostas Lps wrote: >> I am a little confused about how to write this to ruby. >> Any help would be useful! > > Read this first: > http://www.catb.org/~esr/faqs/smart-questions.html#intro You might also try writing a test case to help you figure out what the expected behaviour should be and work towards it: > cat KostasL.rb require 'test/unit' ###/ Code Below \### class A; end class B; end ###\ Code Above /### class KostasLTest < Test::Unit::TestCase def test_001 a = A.new b = B.new a.set_reference(b) result = a.method1 expected = "???" assert_equal(expected, result) end end > ruby KostasL.rb Loaded suite KostasL Started E Finished in 0.001412 seconds. 1) Error: test_001(KostasLTest): NoMethodError: undefined method `set_reference' for # KostasL.rb:16:in `test_001' 1 tests, 0 assertions, 0 failures, 1 errors (So, an obvious next step would be to define a set_reference method in class A; etc.)