Skip to content

fix: class error when passing arguments - #1

Open
gotneb wants to merge 1 commit into
hln33:mainfrom
gotneb:main
Open

fix: class error when passing arguments#1
gotneb wants to merge 1 commit into
hln33:mainfrom
gotneb:main

Conversation

@gotneb

@gotneb gotneb commented Nov 15, 2024

Copy link
Copy Markdown

Hi, Nguyen! 😊

Awesome project! I've been following your code while learning Rust, and it's been incredibly helpful. Thank you for sharing your work—it’s really helping me level up my skills.

I noticed an issue that occurs when arguments are passed to the init method in a class, and I’ve made a small fix to address it. Hope this helps!

class Player {
    // Construtor fails when arguments are passed
    init(name) {
        this.name = name;
    }

    run() {
        print("Player " + this.name + " is running...");
    }
}

//             <here>
var p = Player("Foo");
p.run();

Thanks again for the fantastic project!

This error only happens when arguments are passed to the class init method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant