Finalize if.v

This commit is contained in:
Vinicius Silva 2023-12-23 12:13:49 -03:00
parent 716dbbcdfb
commit a8661b2c60
1 changed files with 39 additions and 2 deletions

View File

@ -1,5 +1,3 @@
pub fn main() pub fn main()
{ {
mut a := 10 mut a := 10
@ -43,6 +41,45 @@ pub fn main()
} }
// ================================================================ // // ================================================================ //
mut arr := [User{"John"}]
u_name := if v := arr[0]
{
v.name
}else
{
"Unamed"
}
println(u_name)
x := Alphabet(Abc{"Test"})
if x is Abc
{
println(x)
}else if x !is Abc
{
println("Not Abc")
}
}
type Alphabet = Abc | Xyz
struct Abc
{
val string
}
struct Xyz
{
foo string
}
struct User {
name string
} }
fn res() !int fn res() !int