2021-03-26 18:46:54 +01:00
|
|
|
struct Company {
|
|
|
|
name string
|
|
|
|
description string
|
|
|
|
}
|
|
|
|
|
|
|
|
fn (lhs Company) == (rhs Company) bool {
|
|
|
|
return lhs.name == rhs.name
|
|
|
|
}
|
|
|
|
|
2020-12-28 17:22:47 +01:00
|
|
|
struct User {
|
2021-03-26 18:46:54 +01:00
|
|
|
name string
|
|
|
|
age int
|
|
|
|
company Company
|
2020-12-28 17:22:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
fn test_struct_equality() {
|
2021-03-26 18:46:54 +01:00
|
|
|
mut usr1 := User{'sanath', 28, Company{'awesome company', 'we are awesome'}}
|
|
|
|
mut usr2 := User{'sanath', 28, Company{'awesome company', 'we are awesome too'}}
|
2020-12-28 17:22:47 +01:00
|
|
|
if usr1 == usr2 {
|
|
|
|
println('Same User')
|
|
|
|
} else {
|
|
|
|
println('Not same User')
|
|
|
|
}
|
|
|
|
assert usr1 == usr2
|
|
|
|
}
|