Documentation for method Capture
assembled from the following pages:
Class: Whatever §
From Whatever
(Whatever) method Capture §
Defined as:
method Capture()
Throws X::Cannot::Capture
.
Role: Blob §
From Blob
(Blob) method Capture §
Defined as:
method Capture(Blob:)
Converts the object to a List
which is, in turn, coerced to a Capture
.
Class: RatStr §
From RatStr
(RatStr) method Capture §
Defined as:
method Capture(RatStr: --> Capture)
Equivalent to Mu.Capture
.
Class: Supply §
From Supply
(Supply) method Capture §
Defined as:
method Capture(Supply: --> Capture)
Equivalent to calling .List.Capture
on the invocant.
Class: Signature §
From Signature
(Signature) method Capture §
Defined as:
method Capture()
Throws X::Cannot::Capture
.
Class: List §
From List
(List) method Capture §
Defined as:
method Capture(List: --> Capture)
Returns a Capture where each Pair, if any, in the List
has been converted to a named argument (with the key of the Pair stringified). All other elements in the List
are converted to positional arguments in the order they are found, i.e. the first non pair item in the list becomes the first positional argument, which gets index 0
, the second non pair item becomes the second positional argument, getting index 1
etc.
my = (7, 5, a => 2, b => 17);my = .Capture;say .keys; # OUTPUT: «(0 1 a b)» my-sub(|); # OUTPUT: «7, 5, 2, 17» sub my-sub(, , :, :)
A more advanced example demonstrating the returned Capture
being matched against a Signature.
my = (7, 5, a => 2, b => 17);say so .Capture ~~ :($ where * == 7,$,:,:); # OUTPUT: «True» = (8, 5, a => 2, b => 17);say so .Capture ~~ :($ where * == 7,$,:,:); # OUTPUT: «False»
Class: Mu §
From Mu
(Mu) method Capture §
Declared as:
method Capture(Mu: --> Capture)
Returns a Capture with named arguments corresponding to invocant's public attributes:
.new.Capture.say; # OUTPUT: «\(:bar("something else"), :foo(42))»
Class: Failure §
From Failure
(Failure) method Capture §
Defined as:
method Capture()
Throws X::Cannot::Capture
if the invocant is a type object or a handled Failure. Otherwise, throws the invocant's exception.
Role: QuantHash §
From QuantHash
(QuantHash) method Capture §
Defined as
method Capture()
Returns the object as a Capture
by previously coercing it to a Hash
.
Class: Map §
From Map
(Map) method Capture §
Defined as:
method Capture(Map:)
Returns a Capture where each key, if any, has been converted to a named argument with the same value as it had in the original Map
. The returned Capture
will not contain any positional arguments.
my = Map.new('a' => 2, 'b' => 17);my = .Capture;my-sub(|); # OUTPUT: «2, 17» sub my-sub(:, :)
Class: Seq §
From Seq
(Seq) method Capture §
Defined as
method Capture()
Coerces the object to a List
, which is in turn coerced into a Capture
Class: ComplexStr §
From ComplexStr
(ComplexStr) method Capture §
Defined as:
method Capture(ComplexStr: --> Capture)
Equivalent to Mu.Capture
.
Class: Int §
From Int
(Int) method Capture §
Defined as:
method Capture()
Throws X::Cannot::Capture
.
Class: Str §
From Str
(Str) method Capture §
Defined as:
method Capture()
Throws X::Cannot::Capture
.
Class: Num §
From Num
(Num) method Capture §
Defined as:
method Capture()
Throws X::Cannot::Capture
.
Class: Capture §
From Capture
(Capture) method Capture §
Defined as:
method Capture(Capture: --> Capture)
Returns itself, i.e. the invocant.
say \(1,2,3, apples => 2).Capture; # OUTPUT: «\(1, 2, 3, :apples(2))»
Role: Callable §
From Callable
(Callable) method Capture §
Defined as:
method Capture()
Throws X::Cannot::Capture
.
Class: Version §
From Version
(Version) method Capture §
Defined as:
method Capture()
Throws X::Cannot::Capture
.
Class: Range §
From Range
(Range) method Capture §
Defined as:
method Capture(Range: --> Capture)
Returns a Capture with values of .min
.max
, .excludes-min
, .excludes-max
, .infinite
, and .is-int
as named arguments.
Class: Channel §
From Channel
(Channel) method Capture §
Defined as:
method Capture(Channel: --> Capture)
Equivalent to calling .List.Capture
on the invocant.