-
-
Save anteaya/794198 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 drive_vehicle(Car.new) | |
21 drive_vehicle(Truck.new) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 class Car < Vehicle | |
10 class Truck < Vehicle |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 def drive_vehicle(v) | |
17 v.drive | |
18 end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 C:\Users\walton.hoops\Desktop>ruby vehicle.rb | |
2 Cruisin in my Car | |
3 Cruisin in my Truck | |
4 Tow that gosh durn Car | |
5 | |
6 C:\Users\walton.hoops\Desktop> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 Cruisin in my Car | |
3 Cruisin in my Truck |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 C:\Users\walton.hoops\Desktop>ruby vehicle.rb | |
2 Cruisin in my Car | |
3 Cruisin in my Truck | |
4 get a long little doggie! | |
5 Tow that gosh durn Car | |
6 | |
7 C:\Users\walton.hoops\Desktop> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 puts "Cruisin in my #{self.class}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 class Vehicle | |
2 def drive | |
3 puts "Cruisin in my #{self.class}" | |
4 end | |
5 end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 class Vehicle | |
2 def drive | |
3 puts "Cruisin in my #{self.class}" | |
4 end | |
5 end | |
6 | |
7 class Car < Vehicle | |
8 end | |
9 | |
10 class Truck < Vehicle | |
11 def tow(target) | |
12 puts "Tow that gosh durn #{target.class}" | |
13 end | |
14 end | |
15 | |
16 def drive_vehicle(v) | |
17 v.drive | |
18 end | |
19 | |
20 drive_vehicle(Car.new) | |
21 drive_vehicle(Truck.new) | |
22 | |
23 Truck.new.tow(Car.new) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 class Vehicle | |
2 def drive | |
3 puts "Cruisin in my #{self.class}" | |
4 end | |
5 end | |
6 | |
7 class Car < Vehicle | |
8 end | |
9 | |
10 class Truck < Vehicle | |
11 def tow(target) | |
12 puts "Tow that gosh durn #{target.class}" | |
13 end | |
14 end | |
15 | |
16 class Cattle | |
17 def self.drive | |
18 puts "get a long little doggie!" | |
19 end | |
20 end | |
21 | |
22 def drive_vehicle(v) | |
23 v.drive | |
24 end | |
25 | |
26 drive_vehicle(Car.new) | |
27 drive_vehicle(Truck.new) | |
28 drive_vehicle(Cattle) | |
29 | |
30 Truck.new.tow(Car.new) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment