Re: auto scope question?

2022-10-25 Thread WhatMeWorry via Digitalmars-d-learn
typeof(screen.output.findSplit("")) s; Perfect. That was the "essence" of my question. But thanks to Ali, I don't have to use such esoteric syntax. D is a wonderful language, but I seem to shoot myself in the foot :)

Re: auto scope question?

2022-10-25 Thread Steven Schveighoffer via Digitalmars-d-learn
On 10/25/22 6:07 PM, WhatMeWorry wrote: I'm naturally getting a undefined identifier `s` error in the return. Is there some way to refactor my code?  I tried to declare s outside of the else brackets like: auto screen = executeShell(cmdLine); auto s; ... {     s = screen.output.findSplit("RE

Re: auto scope question?

2022-10-25 Thread Ali Çehreli via Digitalmars-d-learn
On 10/25/22 15:07, WhatMeWorry wrote: > auto screen = executeShell(cmdLine); > auto s; That can't work because there is no information to infer the type of 's'. Judging from the return type of getPath, perhaps it's string[]: string[] s; This is the question we should answer first: What shoul

auto scope question?

2022-10-25 Thread WhatMeWorry via Digitalmars-d-learn
I'm naturally getting a undefined identifier `s` error in the return. Is there some way to refactor my code? I tried to declare s outside of the else brackets like: auto screen = executeShell(cmdLine); auto s; ... { s = screen.output.findSplit("REG_SZ"); } but that doesn't compile either