-
Notifications
You must be signed in to change notification settings - Fork 0
/
kitchen_sink.rb
127 lines (89 loc) · 1.27 KB
/
kitchen_sink.rb
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
foo
45
attr_reader :bar
# comment
params = {
# key: true,
"another": "value"
}
old_hash = {
# :foo => true,
"another" => "value"
}
@x = :my_symbol
@x
FooBar = 151.56
::FooBar
M1::M2::Baz
::M1::M2
stmt1 = 3; stmt2 = 1
def sum0; false end
def sum1(); true end
def sum2(thing)
45
end
def sum3(thing1, thing2) end
def maybe_sum(a, b, should_do_thing) end
def named_args(foo: true, bar: 3) end
def default_args(x, foo = true, bar = false) end
def mixed_args(foo, bar = 3, baz: nil) end
false
y = [1,2,3]
y.first
n = y[0]
z = y.first
func1 = -> { x = 45 }
func2 = -> (local) { }
func3 = -> (local, _x) {
local.first
}
func3.call(y)
b = 3
a = b
sum1(5)
sum2(1,2)
maybe_sum(3, 5, false)
-> (local, _x) {
local.first
}
class Foo; end
class Bar < Foo; end
module Foo::Bar::Baz; end
module M1
class M2
def sum1(thing)
45
end
end
end
class Foo::Bar
def sum1(some, thing)
thing.call(some)
end
class << self
def thing; end
end
end
y.each_with_object({}) do |x, hash|
hash[x]
end
r.foo = (true)
hash[:foo] = bar
## ---------- FAILURES ----------
# z.without_parens n
# "Hello, #{name}"
# foo { |x| x.bar }
# x.foo true
# <<~MSG
# Hello, name!
# MSG
# <<~MSG.trim
# Hello
# world!
# MSG
# {
# foo: :bar,
# }
# x | 0
# a + b
x