-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinvocation.seg
53 lines (38 loc) · 889 Bytes
/
invocation.seg
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
# Demonstrates the two styles of non-operator method invocation.
def :some_method { |arg0, arg1, arg2|
puts "<<< some_method"
puts "arg0 is #{arg0}"
puts "arg1 is #{arg1}"
puts "arg2 is #{arg2}"
puts ">>>"
}
# Dot invocation.
## Explicit receiver.
self.some_method(10, 20, 30)
## Implicit receiver.
some_method(11, 21, 31)
## Keyword arguments.
some_method(arg2: 12, arg0: 22, arg1: 32)
# Space invocation.
## Explicit receiver.
self.some_method 13 23 33
## Implicit receiver.
some_method 14 24 34
## Keyword arguments (partial).
some_method 15 arg2: 25 arg1: 35
# Default arguments.
def :withdef { |one, two = 2, three = two|
puts "<<< withdef"
puts "one = #{one}"
puts "two = #{two}"
puts "three = #{three}"
puts ">>>"
}
withdef 1
withdef 1 10
withdef 1 10 100
withdef 1 three: 6
# Zero arguments.
def :zeroarg { puts "<<< zeroarg" }
zeroarg()
zeroarg