You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I am running through the koans as my introduction to Elixir, and so far it's been quite nice! I'm a bit confused as to what the purpose of the first structs koan is:
koan "Structs are defined and named after a module" do
person = %Person{}
assert person == ___
end
I started with %{name: nil, age: nil} which of course told me that it wasn't a Structs.Person, so I went with %Person{name: nil, age: nil} which worked, as does %Person{} which...I guess demonstrates that struct equality is based on membership rather than (what I would call) instances? And actually I just went back and discovered that it is even threequal, which is unexpected!
Perhaps this first koan should be something about member equality? It just felt out of step with the rest of the koans to this point, which were pretty clear about what they were demonstrating and what I was expected to fill it in with.
(For context, I'm a fairly experienced developer who spends most of my time in things like Javascript and Python but have wandered far afield, I've enjoyed Rust and Racket and bounced off of Haskell a while back)
The text was updated successfully, but these errors were encountered:
Hey there, Ell. This is great feedback! As I'm looking at it, I too don't quite know the purpose of this koan. It may have been a "stretch" at making the point of the description, but the example itself isn't doing a good job making that point.
A couple ideas come to mind, but I'm not sure I like any them... One would be to dip into the nitty gritty with an assertion like:
assertperson.__struct__==___
I don't love this option, because the __struct__ detail is not very important and would be mostly a distraction to introduce so early.
Another option might be to adjust the description to something like "Structs are map-like data defined and named after a module" along with:
assertis_map(person)
But again I'm not sure that's really helpful and the map-like behavior is revealed in a later koan.
Curious, based on your experience with going through these with fresh eyes, might there have been a way you would have liked to be introduced to structs?
Hello, I am running through the koans as my introduction to Elixir, and so far it's been quite nice! I'm a bit confused as to what the purpose of the first structs koan is:
I started with
%{name: nil, age: nil}
which of course told me that it wasn't a Structs.Person, so I went with%Person{name: nil, age: nil}
which worked, as does%Person{}
which...I guess demonstrates that struct equality is based on membership rather than (what I would call) instances? And actually I just went back and discovered that it is even threequal, which is unexpected!Perhaps this first koan should be something about member equality? It just felt out of step with the rest of the koans to this point, which were pretty clear about what they were demonstrating and what I was expected to fill it in with.
(For context, I'm a fairly experienced developer who spends most of my time in things like Javascript and Python but have wandered far afield, I've enjoyed Rust and Racket and bounced off of Haskell a while back)
The text was updated successfully, but these errors were encountered: