develooper Front page | perl.cvs.parrot | Postings from December 2008

[svn:parrot] r34140 - trunk/languages/perl6/src/classes

From:
pmichaud
Date:
December 20, 2008 04:26
Subject:
[svn:parrot] r34140 - trunk/languages/perl6/src/classes
Message ID:
20081220122643.CACE7CBA12@x12.develooper.com
Author: pmichaud
Date: Sat Dec 20 04:26:42 2008
New Revision: 34140

Modified:
   trunk/languages/perl6/src/classes/Pair.pir

Log:
[rakudo]:  Add .kv method to Pair.


Modified: trunk/languages/perl6/src/classes/Pair.pir
==============================================================================
--- trunk/languages/perl6/src/classes/Pair.pir	(original)
+++ trunk/languages/perl6/src/classes/Pair.pir	Sat Dec 20 04:26:42 2008
@@ -49,16 +49,17 @@
     .return ($P0)
 .end
 
+=item kv
 
-=item value
-
-Gets the value of the pair.
+Return key and value as a 2-element List.
 
 =cut
 
-.sub 'value' :method
-    $P0 = getattribute self, '$!value'
-    .return ($P0)
+.namespace ['Perl6Pair']
+.sub 'kv' :method
+    $P0 = self.'key'()
+    $P1 = self.'value'()
+    .tailcall 'list'($P0, $P1)
 .end
 
 
@@ -71,6 +72,19 @@
 .end
 
 
+=item value
+
+Gets the value of the pair.
+
+=cut
+
+.sub 'value' :method
+    $P0 = getattribute self, '$!value'
+    .return ($P0)
+.end
+
+
+
 =item get_string()  (vtable method)
 
 Stringify the Pair.



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About