I am trying to get the bool to proc the variable change in http://play.golang.org/p/Of8mVuTTPw. Why is it not working?
I am trying to get the bool to proc the variable change in http://play.golang.org/p/Of8mVuTTPw. Why is it not working?
Herd Mastodon with me:
https://linuxrocks.online/invite/ov3SKzQY
it doesnt restart when you mention milk on line 18. all it does is look for the current value of milk. try putting "eggs = true" before the if statement
calling a function after eggs has been set would probably give you the result you were looking for
this code calls a function before eggs has been setCode:package main import "fmt" func main() { var eggs bool buymilk := func() int { if eggs == true { return 6 } else { return 1 } } //milk := buymilk() eggs = true fmt.Println("Mom asked me to buy many bottles of milk?", buymilk()) }
Code:package main import "fmt" func main() { var eggs bool buymilk := func() int { if eggs == true { return 6 } else { return 1 } } milk := buymilk() eggs = true fmt.Println("Mom asked me to buy many bottles of milk?", milk) }
Last edited by wiel; Jul 28, 2013 at 09:18 AM. Reason: eggs
1337
I don't know how. Assigning a value to a boolean type would change it to char or int.So, whatever is done has to be before the decision process? Noted.this code calls a function before eggs has been setCode:package main import "fmt" func main() { var eggs bool buymilk := func() int { if eggs == true { return 6 } else { return 1 } } //milk := buymilk() eggs = true fmt.Println("Mom asked me to buy many bottles of milk?", buymilk()) } //fits very well! #GJ!
Code:package main import "fmt" func main() { var eggs bool buymilk := func() int { if eggs == true { return 6 } else { return 1 } } milk := buymilk() eggs = true fmt.Println("Mom asked me to buy many bottles of milk?", milk) }
Herd Mastodon with me:
https://linuxrocks.online/invite/ov3SKzQY
oh right. that should be eggs = true/falseI don't know how. Assigning a value to a boolean type would change it to char or int.
the code runs in a sequence, not a loop so the if statement would only run once
1337
http://play.golang.org/p/K37nHYSErb seems so far from what the algorithms say though.
Herd Mastodon with me:
https://linuxrocks.online/invite/ov3SKzQY