Examples for https://try.moonbitlang.com/ #1047
-
Hello MoonBitters I don't know if this is the right place to ask, but i would like to know where the examples repository for Try MoonBit Language are located. I wanted to add some extra code to the examples, specifically the struct example, showing how to define/implement functions for a struct. Coming from Rust (just yesterday), it was confusing to see that the online ide from Try was throwing errors when i was writing this: struct Point {
x: Int,
y: Int
}
impl Point {} it would throw them red squiggles 😆 But as i was reading the MoonBit docs, in the Enum section, I came across an eye opener enum Object {
Point(~x : Double, ~y : Double)
Circle(~x : Double, ~y : Double, ~radius : Double)
}
...
fn distance_with(self : Object, other : Object) -> Double!NotImplementedError {...} Seeing this made me realize that we can create struct-specific functions using similar semantics, so I wish to update the example for the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Here is the repo: https://github.com/moonbit-community/ide-examples |
Beta Was this translation helpful? Give feedback.
Here is the repo: https://github.com/moonbit-community/ide-examples