# New Ticket Created by  Erik Johansen 
# Please include the string:  [perl #72582]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=72582 >



>From c15f8ed85399942c573795b8b94acf0376651187 Mon Sep 17 00:00:00 2001
From: Erik Johansen <perl6...@uniejo.dk>
Date: Sat, 6 Feb 2010 18:19:00 +0100
Subject: [PATCH] Add .Bool to Rat and Complex

---
 src/core/Complex.pm |    2 ++
 src/core/Rat.pm     |    2 ++
 2 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/core/Complex.pm b/src/core/Complex.pm
index d25d893..82bd768 100644
--- a/src/core/Complex.pm
+++ b/src/core/Complex.pm
@@ -19,6 +19,8 @@ class Complex {
 
     multi method Complex() { self }
 
+    our Bool multi method Bool() { ( $!re != 0 || $!im != 0 ) ?? Bool::True !! Bool::False }
+
     multi method perl() {
         "Complex.new($.re, $.im)";
     }
diff --git a/src/core/Rat.pm b/src/core/Rat.pm
index a4c9bc9..2c5ee9e 100644
--- a/src/core/Rat.pm
+++ b/src/core/Rat.pm
@@ -31,6 +31,8 @@ class Rat {
 
     multi method perl() { "$!numerator/$!denominator"; }
 
+    our Bool multi method Bool() { $!numerator != 0 ?? Bool::True !! Bool::False }
+
     multi method Num() { $!numerator.Num / $!denominator.Num; }
 
     multi method Rat() { self; }
-- 
1.6.3.3

Reply via email to