Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Update friends.rb example

  • Loading branch information...
commit 8fa19a4e31cbb5a6ff5582ba7368c884819dc5fd 1 parent 7436607
Loren Segal authored

Showing 1 changed file with 3 additions and 2 deletions. Show diff stats Hide diff stats

  1. +3 2 example/friends.rb
5 example/friends.rb
... ... @@ -1,6 +1,7 @@
1 1 require File.dirname(__FILE__) + '/../lib/friend'
2 2
3 3 class Car
  4 + attr_reader :engine
4 5 def initialize; @engine = Engine.new end
5 6
6 7 def turn_on(key)
@@ -25,11 +26,11 @@ def engage; puts "Engine turned on!" end
25 26 car.turn_on("foo")
26 27
27 28 # But we can't enable the engine directly
28   -car.instance_variable_get("@engine").engage
  29 +car.engine.engage
29 30
30 31 # Output:
31 32 # Engine turned on!
32 33 # Car turned on!
33 34 # export.rb:17:in `block in export': `engage' is not accessible outside
34 35 # Engine (NoMethodError)
35   -# from friends.rb:35:in `<main>'
  36 +# from friends.rb:29:in `<main>'

0 comments on commit 8fa19a4

Please sign in to comment.
Something went wrong with that request. Please try again.