Ruby Duck Typing, Classes & Inheritance - University of Washington
CSE 413 Autumn 2008
Ruby Duck Typing, Classes & Inheritance
Overview
Next big topic is typing, classes, and inheritance
But first, a couple of useful things
Shorthand for getters/setters An example of an "each" iterator A little more about blocks vs. Procs
Getters/Setters
Recall that all instance variables are really private ? need to define methods to access them
class PosRat def initialize(num, denom=1) @num = num @denom = denom end
def num @num
end def num=(value)
@num = value end ...
An Alternative
Was:
def num @num
end def denom
@denom end ...
Instead, can use
attr_reader :num, :denom
There is a similar attr_writer shortcut
Iterator Example
Suppose we want to define a class of Sequence objects that have a from, to, and step, and contain numbers x such that
from ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- typing on a computer keyboard
- keyboard lesson eagle mountain saginaw independent school district
- free classes for adults español al reverso spring 2020
- scope sequence
- standards and correlations
- auttior typing and shorthand in the small high school colcradc ed
- typing jungle
- adult esl classes gwinnett county public schools
- basic keyboarding scpl
- lesson 1 english typing basics
Related searches
- university of washington hr jobs
- university of washington jobs listing
- university of washington human resources
- university of washington human resources dept
- university of washington baseball roster
- university of washington product management
- university of washington online mba
- university of washington printable map
- university of washington opioid taper
- university of washington opioid calculator
- university of washington program management
- university of washington graduate programs