exercism / exercism/swift

Updating a player's score in high-score-board has an undefined behavior.

Open
#513 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Swift
Stars
122
Forks
165
PR merge metrics
No merged PRs in 30d

Description

The exercise of updating a player's score has an undefined behavior that is a teachable opportunity. The undefined behavior is what should happen when an attempt is made to update the score of a player who has not been added. There are two possibilities:
- No change should occur (in which case the exercise should test for that and the student should guard against attempting to change a non-exesitant key in the dictionary)
- The new player should be added (in which case the student should use the dictionary's [key base subscript with a default value](https://github.com/apple/swift-evolution/blob/master/proposals/0165-dict.md#2-key-based-subscript-with-default-value) (sorry I couldn't find a better reference)

I can submit a PR for either behavior, but don't know which to prefer teaching.

https://github.com/exercism/swift/blob/f5e15a309465f55441de1f719a409aa1cf97badb/exercises/concept/high-score-board/.docs/instructions.md?plain=1#L56

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.