A quick Ruby Tutorial Part 4 2 forms of assignment problems …
Short Description
A quick Ruby Tutorial, Part 4. COMP313. Source: Programming Ruby, The Pragmatic. Programmers’ Guide by Dave Thomas, Chad. Fowler, and Andy Hunt …
Website: www.cs.waikato.ac.nz | Filesize: 106kb
Content
1
A quick Ruby Tutorial, Part 4
COMP313
Source: Programming Ruby, The Pragmatic
Programmers’ Guide by Dave Thomas, Chad
Fowler, and Andy Hunt
hard coded to variables and constants:
instrument = “piano”
MIDDLE_A = 440
user defined for object attributes and other element references:
song.duration = 234
instrument[”ano”] = “ccolo”
2 forms of assignment
problems
class BrokenAmplifier
attr_accessor :left_channel, :right_channel
def volume=(vol)
left_channel = self.right_channel = vol
end
end
ba = BrokenAmplifier.new
ba.left_channel = ba.right_channel = 99
ba.volume = 5…
Get the file Download here
Related Books:Related Searches: chad fowler, programming ruby, pragmatic programmers, element references, object attributes
Comments
Leave a Reply