-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathuntref.rb
More file actions
60 lines (50 loc) · 777 Bytes
/
untref.rb
File metadata and controls
60 lines (50 loc) · 777 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# Slide: classes
class Person
attr_accessor :name, :age
end
inkel = Person.new
inkel.name = "Leandro"
inkel.age = 33
# Slide: modules
module Say
def self.say
"I'm a module!"
end
end
# Slide: inheritance
class Animal
attr_accessor :kind
end
class Human < Animal
def initialize
@kind = "Human"
end
end
# Slide: extend/include
module Extend
def de_clase
"class method"
end
end
module Include
def de_instancia
"instance method"
end
end
class EI
extend Extend
include Include
end
# Slide: splats
def splats(*args)
p [ args.length, args ]
end
# Slide: monkey patching
class String
def greet
"Hola #{self}!"
end
end
# Slide: lambda
reverse_string_order = lambda { |x, y| y.to_s <=> x.to_s }
square = lambda { |n| n * n }