Closed spmse closed 4 years ago
The example: num2 := 3 s := match num2 { 1 { 'one' } 2 { 'two' } else { println('the input was not matched before') 'many' } }
gives an error on the println statement: expected type string
, but got void
If you leave it out, it works.
Also: enum Animals should be enum Animal, so that the function definitions are consistent with the enum definition.
Last comment: I think it is better to add code so that it is immediately executable, that way the user feels more confident and the code is tested(!) :
fn main() {
cat1 := Animal.cat
gf := Animal.goldfish
println(makes_miau(cat1)) // true
println(is_land_creature(cat1)) // true
println(is_land_creature_alt(gf)) // false
}
Last comment: I think it is better to add code so that it is immediately executable, that way the user feels more confident and the code is tested(!) :
I just pushed tested code into code/match-statement
with 1719d60 where you can see that println
works in a match branch. The docs also say this, but I also noticed that it doesn't work compiling the example I created.
Also added execution examples to the .md
file.
Great!
From: Sven Patrick Meier [mailto:notifications@github.com] Sent: Thursday, November 28, 2019 11:46 AM To: v-community/v_by_example v_by_example@noreply.github.com Cc: ibalbaert ivo.balbaert@telenet.be; Comment comment@noreply.github.com Subject: Re: [v-community/v_by_example] add match statement example (#88)
Also added execution examples to the .md file.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/v-community/v_by_example/pull/88?email_source=notifications&email_token=AAHLG7F4D3IMINFU4UIPUSLQV6OPRA5CNFSM4JSM62OKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFMGVKA#issuecomment-559442600 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHLG7DO46MAZ77RE2BSLOTQV6OPRANCNFSM4JSM62OA . https://github.com/notifications/beacon/AAHLG7CQOFOBVDTZM63BO3LQV6OPRA5CNFSM4JSM62OKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEFMGVKA.gif
@SuicideS3ason thanks for doing this. We need more maintainers to finish writing this book. You're welcome to collaborate more and be part of this.
Looking good. You should also update our
README.md
.
Done in 0cb785a 👍
@SuicideS3ason thanks for doing this. We need more maintainers to finish writing this book. You're welcome to collaborate more and be part of this.
I would love to do that, thank you!
I think indentation should 4 spaces.
should be 4. at least my config says so. 🙈
now it should be correct everywhere.
Hahaha... yeah... it hurts until vfmt
works 😁
haha yeah, but wasn't a vfmt
thing, files on my computer still have correct indentation, but somehow github changed it during push. 😄
@SuicideS3ason thanks for doing this. We need more maintainers to finish writing this book. You're welcome to collaborate more and be part of this.
I just wanted to ask shortly what it means to be maintainer, or if this was an invitation to be maintainer for this project? 🙈 It's my first time contributing in an open source project, but I would love to help you guys!
@SuicideS3ason https://github.com/v-community/v_by_example/invitations 😉
add examples for
match
statement which was defined in issue 45.Closes #45.