We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Proc#[]
#call
1 parent a1a8e86 commit ada0e87Copy full SHA for ada0e87
spec/std/proc_spec.cr
@@ -89,5 +89,10 @@ describe "Proc" do
89
f2.call('r').should eq(2)
90
end
91
92
+ it "#[]" do
93
+ f = ->(x : Int32) { x + 1 }
94
+ f[3].should eq(4)
95
+ end
96
+
97
typeof(-> { 1 }.hash)
98
src/proc.cr
@@ -221,4 +221,16 @@ struct Proc
221
io << '>'
222
nil
223
224
225
+ # Invokes this `Proc` and returns the result.
226
+ #
227
+ # ```
228
+ # add = ->(x : Int32, y : Int32) { x + y }
229
+ # add[1, 2] # => 3
230
231
232
+ # Same as `#call`.
233
+ def [](*args : *T) : R
234
+ call(*args)
235
236
0 commit comments