mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fractions: panic when reciprocal produces invalid fraction
This commit is contained in:
parent
79599b7564
commit
bd34524a1c
@ -79,6 +79,7 @@ pub fn (f1 Fraction) divide(f2 Fraction) Fraction {
|
||||
|
||||
// Fraction reciprocal method
|
||||
pub fn (f1 Fraction) reciprocal() Fraction {
|
||||
if f1.n == 0 { panic('Denominator cannot be zero') }
|
||||
return Fraction{f1.d, f1.n}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user