Tải bản đầy đủ (.pptx) (50 trang)

ruby lecture english lesson

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (232.85 KB, 50 trang )











 
!
"


# $# 

!

%&& 

 
!

'

!
(
)

*


  
!&+&
  

,!+
 
!

'&& 
  
$!
*+

$



-./

0 



 ,



0



  0

!

12$
 $!
3+)
4*+'



()+1  


 
!

(+
(
'
5$$


2"0$
!2

%*67*6"
,08
%"


*"0$!
9.0::.
9.;:

9.<:

'()+
$ 
()
5=

8$ 

'>$  

+"

)

3,!
(+
*?23$
4$4!
@'A%BC?2!

,
"

5 



5 

 


'$D9DD;8$
$+$
'?2,?

 
!% 
2
 !

!*
8

!
5
63!
/:!+
/E!FF6>
G
/H!FF
/-!FFFFG99.
/I!FFFFFF&?&
/J!FFFFG99:
/K!FFFFFF&' &
/L!FFFFG99E

./!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$45!
:!5
E!FF63
H!FFMM 
-!FFFFN%! M;M 
I!FF

J!
5
!
6NB
/:!B
/E!FF
/H!FFFFG
/-!FF
/I!
/J!F
/K!6N%B
/L!N%OB
./!F
!FF6*+
.:!FF+PP
.E!F
.H!FF6*5
!FF5PP
.I!F
.J!FF6* 
.K!FF7
.L!FFFFG9
:/!FF
:.!
N%
635
:9N%!,:H
:!FF6,,Q:
63+
:!FF6,,Q#' #

R=
6
3
FF
FFFF&S6TGU&
FF

6*!62
V
:!3
:!FF6,,Q#S:#
 


530
print array.uniq.sort.reverse

5BV"
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) }


31

3 3

3*))M3*(+

,

31RM3
+33
/!LFFWWFF
FF&F&

(1/.:EH-IJKL
XF.F.F:FEF-FY!FTWWFFF&F&FU
(1..:E-
)!FFW+WFF
+!

%

$'
N

% 2
!

$' 28



!

'$
4  1
& % $$$ $$
>$$$%$!&

(

6F3$F FF2FFFMFFF
F#*F#!M"F1MF6F9QFFF
F! !M"F1MF6F9QFFF
FH!M"F1MF6F9QFFF
'#
&$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

% 

38

9*! 
!6
9Q*
!76
9Q/
31 [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

)  $

22!' 


!

) 
 
!%
!
)
%

+
13
 A3)!33
$

!! !

3$ 
 !



R,
0 $
3;;

N




+]$*?(



N$
)

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×