-
I run the following and get an error, not sure what's going on here struct MyPair[type:AnyType]:
def pairTest() -> Bool:
|
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 8 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Right, exactly! |
Beta Was this translation helpful? Give feedback.
-
@DayDun / @pcupit Please consider revising the answer. @Moosems here is how I impemented the OP's question using generics. Mojo doesn't allow
Prints:
|
Beta Was this translation helpful? Give feedback.
type
here could be any type. If you pass it a dictionary type for example, it doesn't really make sense to callself.first < rhs.first
, that's why it's complaining. The proper solution here is traits, so that you can saytype
isn't just any type, it is any type that can be compared. But until traits are implemented you'll have to useDType
or something to specify numeric types.