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
class PlayingCard | |
attr_accessor :rank, :suite | |
def initialize (rank, suite) | |
@rank = rank | |
@suite = suite | |
end | |
def face_card? | |
['K', 'Q', 'J'].include?(@rank) | |
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
animal = "cat" | |
class << animal | |
def speak | |
puts "miow" | |
end | |
end | |
animal.speak | |
#self is assigned to the object and then the method is found for this class of the object via Singleton (unique methods table). One to the right, one up |
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
max = -1 | |
vowels_hash.each do |vowel, frequency| | |
if frequency > max | |
max = frequency | |
end | |
end |
NewerOlder