Linux server1.dn-server.com 4.18.0-553.89.1.lve.el8.x86_64 #1 SMP Wed Dec 10 13:58:50 UTC 2025 x86_64
LiteSpeed
Server IP : 195.201.204.189 & Your IP : 216.73.216.37
Domains :
Cant Read [ /etc/named.conf ]
User : beriska1
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
opt /
alt /
ruby26 /
share /
ri /
2.6.0 /
system /
Proc /
Delete
Unzip
Name
Size
Permission
Date
Action
%3c%3c-i.ri
637
B
-rw-r--r--
2023-07-26 18:33
%3d%3d%3d-i.ri
455
B
-rw-r--r--
2023-07-26 18:33
%3e%3e-i.ri
636
B
-rw-r--r--
2023-07-26 18:33
%5b%5d-i.ri
1.56
KB
-rw-r--r--
2023-07-26 18:33
arity-i.ri
2.01
KB
-rw-r--r--
2023-07-26 18:33
binding-i.ri
520
B
-rw-r--r--
2023-07-26 18:33
call-i.ri
1.56
KB
-rw-r--r--
2023-07-26 18:33
cdesc-Proc.ri
7.41
KB
-rw-r--r--
2023-07-26 18:33
curry-i.ri
2.08
KB
-rw-r--r--
2023-07-26 18:33
hash-i.ri
389
B
-rw-r--r--
2023-07-26 18:33
inspect-i.ri
232
B
-rw-r--r--
2023-07-26 18:33
lambda%3f-i.ri
3.52
KB
-rw-r--r--
2023-07-26 18:33
new-c.ri
769
B
-rw-r--r--
2023-07-26 18:33
parameters-i.ri
513
B
-rw-r--r--
2023-07-26 18:33
source_location-i.ri
456
B
-rw-r--r--
2023-07-26 18:33
to_proc-i.ri
431
B
-rw-r--r--
2023-07-26 18:33
to_s-i.ri
414
B
-rw-r--r--
2023-07-26 18:33
yield-i.ri
1.56
KB
-rw-r--r--
2023-07-26 18:33
Save
Rename
U:RDoc::NormalClass[iI" Proc:ET@I"Object;To:RDoc::Markup::Document:@parts[o;;[4o:RDoc::Markup::Paragraph;[ I"QA +Proc+ object is an encapsulation of a block of code, which can be stored ;TI"Qin a local variable, passed to a method or another Proc, and can be called. ;TI"GProc is an essential concept in Ruby and a core of its functional ;TI"programming features.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim;[I"#square = Proc.new {|x| x**2 } ;TI" ;TI"square.call(3) #=> 9 ;TI"# shorthands: ;TI"square.(3) #=> 9 ;TI"square[3] #=> 9 ;T:@format0o; ;[I"OProc objects are _closures_, meaning they remember and can use the entire ;TI"(context in which they were created.;T@o;;[I"def gen_times(factor) ;TI"Z Proc.new {|n| n*factor } # remembers the value of factor at the moment of creation ;TI" end ;TI" ;TI"times3 = gen_times(3) ;TI"times5 = gen_times(5) ;TI" ;TI"*times3.call(12) #=> 36 ;TI"*times5.call(5) #=> 25 ;TI"*times3.call(times5.call(4)) #=> 60 ;T;0S:RDoc::Markup::Heading: leveli: textI" Creation;T@o; ;[I"/There are several methods to create a Proc;T@o:RDoc::Markup::List: @type:BULLET:@items[ o:RDoc::Markup::ListItem:@label0;[o; ;[I"$Use the Proc class constructor:;T@o;;[I""proc1 = Proc.new {|x| x**2 } ;T;0o;;0;[o; ;[I";Use the Kernel#proc method as a shorthand of Proc.new:;T@o;;[I"proc2 = proc {|x| x**2 } ;T;0o;;0;[o; ;[I"LReceiving a block of code into proc argument (note the <code>&</code>):;T@o;;[ I"def make_proc(&block) ;TI" block ;TI" end ;TI" ;TI"#proc3 = make_proc {|x| x**2 } ;T;0o;;0;[o; ;[I"KConstruct a proc with lambda semantics using the Kernel#lambda method ;TI"0(see below for explanations about lambdas):;T@o;;[I""lambda1 = lambda {|x| x**2 } ;T;0o;;0;[o; ;[I"RUse the Lambda literal syntax (also constructs a proc with lambda semantics):;T@o;;[I"lambda2 = ->(x) { x**2 } ;T;0S; ;i;I"$Lambda and non-lambda semantics;T@o; ;[I"MProcs are coming in two flavors: lambda and non-lambda (regular procs). ;TI"Differences are:;T@o;;;;[ o;;0;[o; ;[I"6In lambdas, +return+ means exit from this lambda;;To;;0;[o; ;[I"AIn regular procs, +return+ means exit from embracing method ;TI"E(and will throw +LocalJumpError+ if invoked outside the method);;To;;0;[o; ;[I"NIn lambdas, arguments are treated in the same way as in methods: strict, ;TI";with +ArgumentError+ for mismatching argument number, ;TI"+and no additional argument processing;;To;;0;[o; ;[ I"GRegular procs accept arguments more generously: missing arguments ;TI"Lare filled with +nil+, single Array arguments are deconstructed if the ;TI"Hproc has multiple arguments, and there is no error raised on extra ;TI"arguments.;T@o; ;[I"Examples:;T@o;;[I")p = proc {|x, y| "x=#{x}, y=#{y}" } ;TI"&p.call(1, 2) #=> "x=1, y=2" ;TI";p.call([1, 2]) #=> "x=1, y=2", array deconstructed ;TI"@p.call(1, 2, 8) #=> "x=1, y=2", extra argument discarded ;TI"Gp.call(1) #=> "x=1, y=", nil substituted instead of error ;TI" ;TI"+l = lambda {|x, y| "x=#{x}, y=#{y}" } ;TI"&l.call(1, 2) #=> "x=1, y=2" ;TI"Xl.call([1, 2]) # ArgumentError: wrong number of arguments (given 1, expected 2) ;TI"Xl.call(1, 2, 8) # ArgumentError: wrong number of arguments (given 3, expected 2) ;TI"Xl.call(1) # ArgumentError: wrong number of arguments (given 1, expected 2) ;TI" ;TI"def test_return ;TI"M -> { return 3 }.call # just returns from lambda into method body ;TI"7 proc { return 4 }.call # returns from method ;TI" return 5 ;TI" end ;TI" ;TI"*test_return # => 4, return from proc ;T;0o; ;[I"NLambdas are useful as self-sufficient functions, in particular useful as ;TI"Marguments to higher-order functions, behaving exactly like Ruby methods.;T@o; ;[I"1Procs are useful for implementing iterators:;T@o;;[ I"def test ;TI"E [[1, 2], [3, 4], [5, 6]].map {|a, b| return a if a + b > 10 } ;TI"E # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ;TI" end ;T;0o; ;[ I"PInside +map+, the block of code is treated as a regular (non-lambda) proc, ;TI"Lwhich means that the internal arrays will be deconstructed to pairs of ;TI"Jarguments, and +return+ will exit from the method +test+. That would ;TI",not be possible with a stricter lambda.;T@o; ;[I"UYou can tell a lambda from a regular proc by using the #lambda? instance method.;T@o; ;[I"QLambda semantics is typically preserved during the proc lifetime, including ;TI"6<code>&</code>-deconstruction to a block of code:;T@o;;[ I"p = proc {|x, y| x } ;TI"l = lambda {|x, y| x } ;TI")[[1, 2], [3, 4]].map(&p) #=> [1, 2] ;TI"_[[1, 2], [3, 4]].map(&l) # ArgumentError: wrong number of arguments (given 1, expected 2) ;T;0o; ;[I"IThe only exception is dynamic method definition: even if defined by ;TI"Ppassing a non-lambda proc, methods still have normal semantics of argument ;TI"checking.;T@o;;[ I" class C ;TI"# define_method(:e, &proc {}) ;TI" end ;TI"*C.new.e(1,2) #=> ArgumentError ;TI"1C.new.method(:e).to_proc.lambda? #=> true ;T;0o; ;[I"MThis exception ensures that methods never have unusual argument passing ;TI"Kconventions, and makes it easy to have wrappers defining methods that ;TI"behave as usual.;T@o;;[ I" class C ;TI"" def self.def2(name, &body) ;TI"$ define_method(name, &body) ;TI" end ;TI" ;TI" def2(:f) {} ;TI" end ;TI"*C.new.f(1,2) #=> ArgumentError ;T;0o; ;[I"NThe wrapper <i>def2</i> receives <code>body</code> as a non-lambda proc, ;TI"5yet defines a method which has normal semantics.;T@S; ;i;I")Conversion of other objects to procs;T@o; ;[I"KAny object that implements the +to_proc+ method can be converted into ;TI"Aa proc by the <code>&</code> operator, and therefore con be ;TI"consumed by iterators.;T@o;;[I"class Greater ;TI" def initialize(greating) ;TI" @greating = greating ;TI" end ;TI" ;TI" def to_proc ;TI"1 proc {|name| "#{@greating}, #{name}!" } ;TI" end ;TI" end ;TI" ;TI"hi = Greater.new("Hi") ;TI"hey = Greater.new("Hey") ;TI"?["Bob", "Jane"].map(&hi) #=> ["Hi, Bob!", "Hi, Jane!"] ;TI"A["Bob", "Jane"].map(&hey) #=> ["Hey, Bob!", "Hey, Jane!"] ;T;0o; ;[I"EOf the Ruby core classes, this method is implemented by Symbol, ;TI"Method, and Hash.;T@o;;[ I"-:to_s.to_proc.call(1) #=> "1" ;TI"4[1, 2].map(&:to_s) #=> ["1", "2"] ;TI" ;TI"0method(:puts).to_proc.call(1) # prints 1 ;TI"3[1, 2].each(&method(:puts)) # prints 1, 2 ;TI" ;TI"/{test: 1}.to_proc.call(:test) #=> 1 ;TI":%i[test many keys].map(&{test: 1}) #=> [1, nil, nil];T;0: @fileI"proc.c;T:0@omit_headings_from_table_of_contents_below0;0;0[ [ [ [[I" class;T[[:public[[I"new;TI"proc.c;T[:protected[ [:private[ [I" instance;T[[;[[I"<<;T@[I"===;T@[I">>;T@[I"[];T@[I" arity;T@[I"binding;T@[I" call;T@[I" curry;T@[I" hash;T@[I"inspect;T@[I"lambda?;T@[I"parameters;T@[I"source_location;T@[I"to_proc;T@[I" to_s;T@[I" yield;T@[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;0;0[@�@�cRDoc::TopLevel