Creating a struct

I started with Mojo manual and want to create this struct:
I copied the code from the website:
But when I compile:

error: expected ‘)’ in argument list
fn init(out self, first: Int, second: Int):

Any idea what is going one here?

struct MyPair:
var first: Int
var second: Int

fn __init__(out self, first: Int, second: Int):
    self.first = first
    self.second = second

I suspect you’re using an old version of Mojo. The out keyword was added in 24.6, which was released last week.

On 24.6, I get the same error as you if I use a non-existent keyword in place of out:

struct MyPair:
    var first: Int
    var second: Int

    fn __init__(potato self, first: Int, second: Int):
        self.first = first
        self.second = second
error: expected ')' in argument list
    fn __init__(potato self, first: Int, second: Int):
                       ^

Notice that the terminal puts an arrow below the token that it doesn’t expect to encounter. I expect for you, the arrow is also pointing to self. If so, this is because out is not a keyword in the version of Mojo that you’re using.

This error message isn’t very informative, so I’d filed a Github issue to improve it.