From: Matthew Smillie Date: 2006-08-10T01:30:52+09:00 Subject: Re: Why is this returning nil? On Aug 9, 2006, at 17:23, Dark Ambient wrote: > class User > > def initialize(level, status) > @level = level > @status = status > end > > def finda > if @status == "active" > print #{@level} > else > puts "user not exist" > end > end > end > > user1 = User.new(1, "active") > user2 = User.new(1, "inactive") > user3 = User.new(2, "active") > user4 = User.new(3, "inactive") > > user1.finda > > Something wrong ..not sure > TIA > Stuart Because methods return the value of the last statement. In this case, both 'puts' and 'print' return nil, the actual output to the screen is separate from the return value: print "Hello\n" Hello => nil puts "Hello" Hello => nil My guess/advice would be to return the actual string you're eventually going to output, and deal with the actual output elsewhere in the code. matthew smillie.