-
-
Save modularbot/c67e0a66a97aa32314d248f4721f75e2 to your computer and use it in GitHub Desktop.
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
from utils.variant import Variant | |
fn print_value(value: Variant[Int, Float64], end: StringLiteral) -> None: | |
if value.isa[Int](): | |
print(value.get[Int]()[], end=end) | |
else: | |
print(value.get[Float64]()[], end=end) | |
fn main() -> None: | |
var a = List[Variant[Int, Float64]](1, 2.5, 3, 4.5, 5) | |
print("List(", end="") | |
for i in range(len(a) - 1): | |
print_value(a[i], ", ") | |
print_value(a[-1], "") | |
print(")") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment