Re: [go-nuts] Why is the omitted expression in a swtich code block a typed bool "true"?

2018-02-02 Thread 'Axel Wagner' via golang-nuts
I did end up asking git, why this was done and it gave this answer , which links to this discussion . Hope that helps On Fri, Feb 2, 2018 at 5:18 PM, wrote:

Re: [go-nuts] Why is the omitted expression in a swtich code block a typed bool "true"?

2018-02-02 Thread digg
On Friday, February 2, 2018 at 10:45:58 AM UTC-5, Axel Wagner wrote: > > From the spec: > > >> If the switch expression evaluates to an untyped constant, it is first >> converted to its default type; if it is an untyped boolean value, it is >> first converted to type bool. The predeclared

Re: [go-nuts] Why is the omitted expression in a swtich code block a typed bool "true"?

2018-02-02 Thread digg
On Friday, February 2, 2018 at 10:37:24 AM UTC-5, di...@veryhaha.com wrote: > > > > On Friday, February 2, 2018 at 10:27:04 AM UTC-5, Ian Lance Taylor wrote: >> >> On Fri, Feb 2, 2018 at 7:10 AM, wrote: >> > >> > Why not make it untyped? >> > >> > package main >> > >>

Re: [go-nuts] Why is the omitted expression in a swtich code block a typed bool "true"?

2018-02-02 Thread digg
On Friday, February 2, 2018 at 10:37:24 AM UTC-5, di...@veryhaha.com wrote: > > > > On Friday, February 2, 2018 at 10:27:04 AM UTC-5, Ian Lance Taylor wrote: >> >> On Fri, Feb 2, 2018 at 7:10 AM, wrote: >> > >> > Why not make it untyped? >> > >> > package main >> > >>

Re: [go-nuts] Why is the omitted expression in a swtich code block a typed bool "true"?

2018-02-02 Thread digg
On Friday, February 2, 2018 at 10:27:04 AM UTC-5, Ian Lance Taylor wrote: > > On Fri, Feb 2, 2018 at 7:10 AM, > wrote: > > > > Why not make it untyped? > > > > package main > > > > type T bool > > > > func f() T {return T(false)} > > > > func main() { > >

Re: [go-nuts] Why is the omitted expression in a swtich code block a typed bool "true"?

2018-02-02 Thread Ian Lance Taylor
On Fri, Feb 2, 2018 at 7:10 AM, wrote: > > Why not make it untyped? > > package main > > type T bool > > func f() T {return T(false)} > > func main() { > switch { > case f(): // invalid case f() in switch (mismatched types T and bool) > } > } The current language

[go-nuts] Why is the omitted expression in a swtich code block a typed bool "true"?

2018-02-02 Thread digg
Why not make it untyped? package main type T bool func f() T {return T(false)} func main() { switch { case f(): // invalid case f() in switch (mismatched types T and bool) } } -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To