2. What is the Ruby?
meaning reading and writing Ruby is really easy
it looks a lot like regular English!High-level
meaning you don't need a compiler to write and run Ruby.InterpretedInterpreted
everything in Ruby is an object.Object-oriented
Marts design a language that emphasized human needs over tho
se of the computer, which is why Ruby is so easy to pick up.Easy to use
11. Method in Ruby
Method form in ruby
def (parameter1, parameter2, parameter3)
Doing Something
end
Parentheses are usually optional in Ruby.
覲危 parameter 轟 襴伎 螳 牛.
end
12. Method in Ruby
Implicit Return
Parentheses are usually optional in Ruby.
覲危 parameter 轟 襴伎 螳 牛.
Interpolation 覲願覯
13. Interpolation
Interpolation
Interpolation allows Ruby code to appear within a string. The result of evaluating t
hat code is inserted into the string:
"1 + 2 = #{1 + 2}" #=> "1 + 2 = 3"
#{expression}
14. The end of the sentence
Usually, Every sentence should be ended by semi-colon in Java or C
But in Ruby, Dont care about it.
覿覓語(伎伎)
覓語(譬襭)覓語(譬襭)
覓語レ郁屋
15. Interpolation
Interpolation
Interpolation allows Ruby code to appear within a string. The result of evaluating t
hat code is inserted into the string:
"1 + 2 = #{1 + 2}" #=> "1 + 2 = 3"
#{expression}
16. Dynamic Typing
Ruby is dynamically typed: the type of a variable is generally not inferable until
runtime. So s=5 can follow s= foo in the same block of code.
Because variables do not have types.
17. Dynamic Typing
Ruby is dynamically typed: the type of a variable is generally not inferable until
runtime. So s=5 can follow s= foo in the same block of code.
Because variables do not have types.
18. Dynamic Typing
Ruby is dynamically typed: the type of a variable is generally not inferable until
runtime. So s=5 can follow s= foo in the same block of code.
Because variables do not have types.
19. Every Operation is a Method Call
every operation is a method call, note that even basic math operations
such as +, *, = = (equality comparison) are syntactic sugar for method calls
20. Every Operation is a Method Call
every operation is a method call, note that even basic math operations
such as +, *, = = (equality comparison) are syntactic sugar for method calls
syntactic sugar ( 危危螻 所 蠍 所 貉危 語企ゼ 誤 覓碁Д)
(computing) Additions to a computer language that make code easier for humans
to read or write, but that do not change the functionality or expressiveness of the
language. -Wikipidea
22. Every Operation is a Method Call
企れ 螳豌
(Fixnum,Symbol,true,nill 讀 螳 螳 螳豌企 覿螳)
ObjectSpace.each_object(Some_class) {|x| p x}
襴 (Reflection)
23. Every Operation is a Method Call
語ろ伎る伎 覃
instance name.respond_to(method name)
襴 (Reflection)
24. Every Operation is a Method Call
螳豌(語ろ伎) 伎 危エ覲企 蟆 襴 豸° 訖
豌 蠏碁殊 至鍵 伎 企れ 伎 .
襴 (Reflection)
25. Every Operation is a Method Call
螳豌(語ろ伎) 伎 危エ覲企 蟆 襴 豸° 訖
豌 蠏碁殊 至鍵 伎 企れ 伎 .
襴 (Reflection)
26. Every Operation is a Method Call
if something looks like a duck and quacks like a duck, it might as well be a duck.
るΜ豌 覲伎願, るΜ豌 碁, 蠏瑚唄 るΜ 蟆企.
螳豌伎 企れ 伎螳 , 覓伎 螳 蟆一 蟆企.
Duck Typing ; ( Viewpoint, philosophy )
EverythingEverything
is object
in Ruby.
Reflection.
Typing
Duck
Typing
27. Every Operation is a Method Call
if something looks like a duck and quacks like a duck, it might as well be a duck.
るΜ豌 覲伎願, るΜ豌 碁, 蠏瑚唄 るΜ 蟆企.
螳豌伎 企れ 伎螳 , 覓伎 螳 蟆一 蟆企.
Duck Typing ; ( Viewpoint, philosophy )
豺
覦磯
蟆讌?
豺襷 覦朱 OK! 豺襷 螻螳 覦朱 OK!
28. Every Operation is a Method Call
if something looks like a duck and quacks like a duck, it might as well be a duck.
るΜ豌 覲伎願, るΜ豌 碁, 蠏瑚唄 るΜ 蟆企.
螳豌伎 企れ 伎螳 , 覓伎 螳 蟆一 蟆企.
Duck Typing ; ( Viewpoint, philosophy )
Fileopen.class 殊願鍵class FileManagement{class FileManagement{
class FileManagement{
public void main(String Args[])
Fileopen.class
Modify.class
Save.class
殊願鍵
蠍
ロ蠍
class FileManagement{
public void main(String Args[])
if ( ! Fileopen 語ろ伎?){}
if ( ! Modify 語ろ伎?){}
if ( ! Save 語ろ伎?){}
}
class FileManagement{
public void main(String Args[])
if ( ! Fileopen 蠍磯レ 螳?){}
if ( ! Modify 蠍磯レ 螳?){}
if ( ! Save 蠍磯レ 螳?){}
}
if ( ! Fileopen 蠍磯レ 螳?){}
if ( ! Modify 蠍磯レ 螳?){}
if ( ! Save 蠍磯レ 螳?){}
襭觜 Dynamic typing朱 誤 覲
螳覲企.
磯殊 螳 覦襯願, 襷豢
覃 .
るΜ豌 覲伎願, るΜ豌 碁企
. 覦譯殊(laissez-faire)
}
29. Every Operation is a Method Call
Duck Typing ; ( Viewpoint, philosophy )
企 觜蟲 - JAVA, C#
30. Every Operation is a Method Call
Duck Typing ; ( Viewpoint, philosophy )
螳豌 覲伎 (覃) 蠍一 蟆
31. Every Operation is a Method Call
Duck Typing ; ( Viewpoint, philosophy )
覦譯殊ろ (laissez-faire)
32. Every Operation is a Method Call
lets us define new code at runtime.
覃襦蠏碁覦(metaprogramming)
42. Blocks and Yield
Def call_back
puts Start of method
yield
yield
puts End of method
End
Result :
Start of method
In the block
In the block
End of method
Yield : 蟆譯朱,
語ろ伎る.覃覈(argument) {|parameter| doing something.}
End
Call_block {puts In the block}
Def call_block
yield(hello, 99)
End
call_block {|str, num| } blockblock
50. Proc & Lambda : Savable Blocks!
Proc Lambda
Checking Arguments X O
if you pass it the wrong number of
arguments
Ignore
andassign nil
throw an error
control back to the calling method X O
讀譬襭 旧蟠覦
64. Modules & Mix-in
mix-in :
A mix-in is a set of related behaviors that can be added to any class.-
Fox, Armando; Patterson, David (2014-01-03). Engineering Software as a Service: An
Agile Approach Using Cloud Computing
NinJA
test
1
NinJA
NinJASon
test
1
test
2
覈
讌 .