We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go version
$ go version go version go1.13.6 darwin/amd64
go env
$ go env GO111MODULE="on" GOARCH="amd64" GOBIN="" GOCACHE="/Users/amitbasuri/Library/Caches/go-build" GOENV="/Users/amitbasuri/Library/Application Support/go/env" GOEXE="" GOFLAGS=" -mod=" GOHOSTARCH="amd64" GOHOSTOS="darwin" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/amitbasuri/goWork" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/Users/amitbasuri/sdk-go/go1.13.6" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/Users/amitbasuri/sdk-go/go1.13.6/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/amitbasuri/goWork/src/go-algo/go.mod" CGO_CFLAGS="-g -O2" CGO_CPPFLAGS="" CGO_CXXFLAGS="-g -O2" CGO_FFLAGS="-g -O2" CGO_LDFLAGS="-g -O2" PKG_CONFIG="pkg-config" GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/9c/68n6djhd0yld73s97pfgyz0r0000gq/T/go-build587761073=/tmp/go-build -gno-record-gcc-switches -fno-common" GOROOT/bin/go version: go version go1.13.6 darwin/amd64 GOROOT/bin/go tool compile -V: compile version go1.13.6 uname -v: Darwin Kernel Version 17.7.0: Sun Dec 1 19:19:56 PST 2019; root:xnu-4570.71.63~1/RELEASE_X86_64 ProductName: Mac OS X ProductVersion: 10.13.6 BuildVersion: 17G10021 lldb --version: lldb-902.0.79.7 Swift-4.1
I figured out something weird happening with the for loop, Please find my code below. https://play.golang.org/p/gD8uCtJURYq
for
The loop for root != nil || len(stack) > 0 { ...} should not exit if the value evaluates to true on the previous iteration.
for root != nil || len(stack) > 0 { ...}
true
The loop exits even if it evaluates to true.
The text was updated successfully, but these errors were encountered:
The statement
root := stack[len(stack)-1]
shadows the root variable used by the loop condition. You may want to use = rather than := there.
root
=
:=
Sorry, something went wrong.
No branches or pull requests
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I figured out something weird happening with the
for
loop, Please find my code below.https://play.golang.org/p/gD8uCtJURYq
What did you expect to see?
The loop
for root != nil || len(stack) > 0 { ...}
should not exit if the value evaluates totrue
on the previous iteration.What did you see instead?
The loop exits even if it evaluates to
true
.The text was updated successfully, but these errors were encountered: