This was a weird Ruby gotcha that my coworker, Paul Jones, discovered. Here’s a test class to show the point:

class T
  private
  def l=(val); puts val end
  def l; 1 end

  public
  def m=(val); self.l=val end
  def m; self.l end
end

irb> t.m=1
1
=> 1

irb> t.m
NoMethodError: private method `l' called for #
        from (irb):11:in `m'
        from (irb):18

Anyone know why this is the case?

Update: Perhaps I should clarify. I was expecting the “m=” method to work as it did, but I did not expect the NoMethodError when calling “m”. A better question might be, “Why the discrepency?”