Skip to content

Comments

Use with statement in bank-account specs#81

Open
glennj wants to merge 1 commit intoexercism:mainfrom
glennj:bank-account-tests-use-with
Open

Use with statement in bank-account specs#81
glennj wants to merge 1 commit intoexercism:mainfrom
glennj:bank-account-tests-use-with

Conversation

@glennj
Copy link
Contributor

@glennj glennj commented Feb 24, 2026

Simply to demonstrate how with works.

https://moonscript.org/reference/#the-language/with-statement

Questions:

  1. is it an improvement?
  2. does it help show the student how with works?
  3. do I need an instructions.append file to document it?

@github-actions
Copy link

This PR touches files which potentially affect the outcome of the tests of an exercise. This will cause all students' solutions to affected exercises to be re-tested.

If this PR does not affect the result of the test (or, for example, adds an edge case that is not worth rerunning all tests for), please add the following to the merge-commit message which will stops student's tests from re-running. Please copy-paste to avoid typos.

[no important files changed]

For more information, refer to the documentation. If you are unsure whether to add the message or not, please ping @exercism/maintainers-admin in a comment. Thank you!

@BNAndras
Copy link
Member

Is it an improvement?
Yeah, this would be idiomatic Moonscript, and seeing idiomatic code in use is always a good idea.

does it help show the student how with works?
I think so, because it's clear we're doing a sequence of operations. There might be some confusion over whether we're passing a single mutable bank account through a series of operations or we're passing new immutable bank accounts after every operation. However, the first few tests definitely show the former to be true.

do I need an instructions.append file to document it?
I don't believe, since it doesn't affect how a student might start solving an exercise. This would definitely be good to bring up in a concept if Moonscript gets a syllabus.

@oxe-i
Copy link

oxe-i commented Feb 24, 2026

I'm still learning about moonscript, but I'm generally in favor of using exercises as an opportunity to expose students to different topics. Sometimes this is some computer science-y general topic, sometimes it is some aspect of the language. Adding with here seems like a good change in this direction.

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.

3 participants