!
"
# $#
!
%&&
!
'
!
(
)
*
!&+&
,!+
!
'&&
$!
*+
$
-./
0
,
0
0
!
12$
$!
3+)
4*+'
()+1
!
(+
(
'
5$$
2"0$
!2
%*67*6"
,08
%"
*"0$!
9.0::.
9.;:
9.<:
'()+
$
()
5=
8$
'>$
+"
)
3,!
(+
*?23$
4$4!
@'A%BC?2!
,
"
5
5
'$D9DD;8$
$+$
'?2,?
!%
2
!
!*
8
!
5
63!
/:!+
/E!FF6>
G
/H!FF
/-!FFFFG99.
/I!FFFFFF&?&
/J!FFFFG99:
/K!FFFFFF&' &
/L!FFFFG99E
./!FFFFFF&'&
!FFFF
.:!FF
.E!
5
Stringify makes use
of a @value
instance variable.
The class that will
be mixed with this
module needs to
define and set a
@value instance
variable
a module could
invoke methods
defined not in the
module itself but in
the class that it will
be mixed with.
6*5$45!
:!5
E!FF63
H!FFMM
-!FFFFN%! M;M
I!FF
J!
5
!
6NB
/:!B
/E!FF
/H!FFFFG
/-!FF
/I!
/J!F
/K!6N%B
/L!N%OB
./!F
!FF6*+
.:!FF+PP
.E!F
.H!FF6*5
!FF5PP
.I!F
.J!FF6*
.K!FF7
.L!FFFFG9
:/!FF
:.!
N%
635
:9N%!,:H
:!FF6,,Q:
63+
:!FF6,,Q#' #
R=
6
3
FF
FFFF&S6TGU&
FF
6*!62
V
:!3
:!FF6,,Q#S:#
530
print array.uniq.sort.reverse
5BV"
ary.sort!
? returns a true or false
◦
examples: defined? equal?
! changes the object that calls the method
(do it here!)
%N$!)
files.each { |file| process(file) }
31
◦
3 3
◦
3*))M3*(+
◦
,
31RM3
+33
/!LFFWWFF
FF&F&
(1/.:EH-IJKL
XF.F.F:FEF-FY!FTWWFFF&F&FU
(1..:E-
)!FFW+WFF
+!
%
$'
N
% 2
!
$' 28
!
'$
4 1
& % $$$ $$
>$$$%$!&
(
6F3$F FF2FFFMFFF
F#*F#!M"F1MF6F9QFFF
F! !M"F1MF6F9QFFF
FH!M"F1MF6F9QFFF
'#
&$1&2>$$$$
2$!
2
!
$'
$
>$
#Z$V#
#(!!!#
C
$
#A$V#
#+!!!#
$
>$
#Z$V#
$'
If you are calling
“quack”, Duck and
DuckRecording are
interchangeable
If you are calling
“swim”, Duck and
Goose are
interchangeable.
Method isn’t
expecting a specific
type JUST one with
the needed
functionality.
*$??(1
2
%
38
9*!
!6
9Q*
!76
9Q/
31 [7\*!%8 $?2
7!%8
[M\!
)
'1
The new search path
foobar = Array.new
def foobar.size // Adds a size method ONLY for the instance
“Infinity and beyond" ;
end
) $
22!'
!
)
!%
!
)
%
+
13
A3)!33
$
!! !
3$
!
R,
0 $
3;;
N
◦
◦
+]$*?(
◦
◦
N$
)