Skip to content

Incorrect Struct Field Usage in Numbers Initialization Example under "What are the Different Visibility Specifiers?" Topic #840

@GillHapp

Description

@GillHapp

Hi team 👋,

I'm going through the course "Build on Move on Sui and Explore its Applications", and I found a potential mistake in the example provided under the topic:

➡️ Topic: What are the Different Visibility Specifiers?
➡️ Section: Code snippet explaining object instantiation

Here’s the code from the course:

struct Numbers has key {
	id: UID,
	a: u8,
	b: u8,
}

fun init(a: u8, b: u8, ctx: &mut TxContext) {
	let numbers = Numbers {
		id: object::new(ctx),
		name: string::utf8(name_bytes)
	};
}

🔴 Issue:
The struct Numbers is defined with the fields id, a, and b, but in the init function, the object is being instantiated with a name field — which does not exist in the struct definition.

Expected Fix:
Either update the Numbers struct to include a name field, or correct the instantiation to use the right fields (a and b).

Example fix:

let numbers = Numbers {
	id: object::new(ctx),
	a: a,
	b: b
};

Please confirm if this is an oversight or if the struct is supposed to include name.

Thanks for the great course 🙏 — loving the hands-on learning with Move and Sui!

Best regards,
Harpreet Gill

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions