Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #2990 from sshaw/patch-1
Ruby fixes
  • Loading branch information
JJ committed Sep 1, 2019
2 parents cbf3f57 + d2f78a4 commit 4e819fb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions doc/Language/rb-nutshell.pod6
Expand Up @@ -127,7 +127,7 @@ $n < 1; # Perl 6
=end item
=head2 C«.» Method calls, C<.send>
=head2 C«.» Method calls, C<.public_send>
Method call syntax uses a dot just like Ruby:
Expand All @@ -140,7 +140,7 @@ $person.name # Perl 6
To call a method whose name is not known until runtime:
=for code :lang<ruby>
object.send(methodname, args); # Ruby
object.public_send(methodname, args); # Ruby
=for code
my $object; my Str $methodname; my @args; ...;
$object."$methodname"(@args); # Perl 6
Expand Down Expand Up @@ -263,10 +263,10 @@ say %calories« $keys ».join(','); # Perl 6, interpolated split
I<Key/value-slicing>
=for code :lang<ruby>
say calories.slice('pear', 'plum').join(','); # Ruby, with ActiveRecord
puts calories.slice('pear', 'plum') # Ruby >= 2.5
=for code :preamble<my %calories>
say %calories{'pear', 'plum'}:kv.join(','); # Perl 6 - use :kv adverb
say %calories<pear plum>:kv.join(','); # Perl 6 (prettier version)
say %calories{'pear', 'plum'}:kv.Hash; # Perl 6 - use :kv adverb
say %calories<pear plum>:kv.Hash; # Perl 6 (prettier version)
=end item
=head3 C<&> Sub
Expand Down Expand Up @@ -1035,12 +1035,12 @@ $person.^attributes;
Like Ruby, in Perl 6, everything is an object, but not all operations are
equivalent to C<.send>. Many operators are global functions that use typed
equivalent to C<.public_send>. Many operators are global functions that use typed
multi-dispatch (function signatures with types) to decide which implementation
to use.
=for code :lang<ruby>
5.send(:+, 3) # => 8, Ruby
5.public_send(:+, 3) # => 8, Ruby
=for code
&[+](5, 3) # => 8, Perl 6, reference to infix addition operator
&[+].^candidates # Perl 6, lists all signatures for the + operator
Expand Down

0 comments on commit 4e819fb

Please sign in to comment.