Closed TodePond closed 1 year ago
Some different options:
const Player = struct ({
score: 0,
health: 10,
name: "",
})
const lu = Player({name: "Lu"})
const Player = (options = {}) => ({
score: 0,
health: 10,
name: "",
...options,
})
const lu = Player({name: "Lu"})
just scrap it
it's gone
I'm tempted to use
struct
as more of a class, with a constructor and stuff. But this feels like a bad idea. But then also there's no way to combine the use of struct with classes.And also, it kinda sucks when default values are objects/arrays because it doesn't create a new one each time.
And also I sometimes use struct for default arguments, which I should probably just do with a spread.
Maybe just get rid of it until I can be better behaved.