-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes issue where Int to Float conversion would fail and would not sh…
…ow the numbers
- Loading branch information
marko
committed
Jul 20, 2021
1 parent
6c1d02b
commit e6c407b
Showing
3 changed files
with
56 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// Number.swift | ||
// Infected | ||
// | ||
// Created by marko on 7/21/21. | ||
// | ||
|
||
import Foundation | ||
|
||
enum Number { | ||
case integer(Int) | ||
case decimal(Float) | ||
|
||
var intValue: Int { | ||
switch self { | ||
case let .integer(value): | ||
return value | ||
case let .decimal(value): | ||
return Int(value) | ||
} | ||
} | ||
|
||
var floatValue: Float { | ||
switch self { | ||
case let .integer(value): | ||
return Float(value) | ||
case let .decimal(value): | ||
return value | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters