Hello! My name is Thomas and I'm a nerd. I like tech and gadgets and speculative fiction, and playing around with programming. It's not my day job, but I'm working on making it a side gig :)
It provides an automatic default return variable called "result" that you can just start stuffing things into and it will automatically return it without you doing anything :)
letrate=40.0weekly_discount=50.0weekend_discount=20.0test_data=[1,2,3,4,5,6,7,8,9]proc total_cost(days:int):float=result=days.float*rateifdays>=7:result-=weekly_discountelifdays>=3:result-=weekend_discountfornintest_data:echo"Cost for ",n," days is: ",total_cost(n)
I try to use the func keyword when defining methods, that way the compiler can guarantee that I have pure function with no side effects. func is just sugar for proc {.noSideEffect.}.
Hello! My name is Thomas and I'm a nerd. I like tech and gadgets and speculative fiction, and playing around with programming. It's not my day job, but I'm working on making it a side gig :)
I haven't gotten into the habit of doing that yet. I know I should and I think it's a great idea in general, but years of habits are hard to break and the func keyword is still a fairly recent addition to the language :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
My solution in Nim, my new favourite language :)
It provides an automatic default return variable called "result" that you can just start stuffing things into and it will automatically return it without you doing anything :)
I try to use the
funckeyword when defining methods, that way the compiler can guarantee that I have pure function with no side effects.funcis just sugar forproc {.noSideEffect.}.I haven't gotten into the habit of doing that yet. I know I should and I think it's a great idea in general, but years of habits are hard to break and the func keyword is still a fairly recent addition to the language :)