You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import"fmt"import"reflect"funcmain() {
varnilArray []string=nilemptyArray:= []string{}
if!reflect.DeepEqual(nilArray, emptyArray) {
fmt.Printf("They are different as expected, let's see if this is going to be helpful message, like you would like to receive in some test\n")
fmt.Printf("Expected:\n%+v\nGot:\n%+v\n", nilArray, emptyArray)
}
}
I would expect it to print something like:
Expected:
<nil>
Got:
[]
but instead, I'm getting:
Expected:
[]
Got:
[]
Tracking what actually is different might be a PITA in some more complex data structures.
The text was updated successfully, but these errors were encountered:
@cznic: Thanks for the hint. But the point probably still stands.
ianlancetaylor
changed the title
fmt: Empty array and nil array are printed both as empty array.
fmt: Empty slice and nil slice are printed both as empty slice
Sep 29, 2015
Please see following snippet (also saved in http://play.golang.org/p/bTc5CWT--P):
I would expect it to print something like:
but instead, I'm getting:
Tracking what actually is different might be a PITA in some more complex data structures.
The text was updated successfully, but these errors were encountered: