go 언어의 selector
For a primary expression
x that is not a package name, the selector expression x.f
denotes the field or method
f of the value x (or sometimes *x ; see below). The identifier f is called the (field or method) selector; it must not be the blank identifier. The type of the selector expression is the type of f . If x is a package name, see the section on qualified identifiers. A selector
f may denote a field or method f of a type T , or it may refer to a field or method f of a nested anonymous field of T . The number of anonymous fields traversed to reach f is called its depth in T . The depth of a field or method f declared in T is zero. The depth of a field or method f declared in an anonymous field A in T is the depth of f in A plus one. The following rules apply to selectors:
x of type T or *T where T is not an interface type, x.f denotes the field or method at the shallowest depth in T where there is such an f . If there is not exactly one f with shallowest depth, the selector expression is illegal. x of type I where I is an interface type, x.f denotes the actual method with name f of the value assigned to x . If there is no method with name f in the method set of I , the selector expression is illegal. x.f is illegal. x is of pointer type and has the value nil and x.f denotes a struct field, assigning to or evaluating x.f causes a run-time panic. x is of interface type and has the value nil , calling or evaluating the method x.f causes a run-time panic. Selectors automatically dereference pointers to structs. If
x is a pointer to a struct, x.y is shorthand for (*x).y ; if the field y is also a pointer to a struct, x.y.z is shorthand for (*(*x).y).z , and so on. If x contains an anonymous field of type *A , where A is also a struct type, x.f is shorthand for (*x.A).f . 원문 http://golang.org/ref/spec#Selectors
다음으로 전송:https://www.cnblogs.com/fishincat/p/4116372.html
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Is Eclipse IDE dying?In 2014 the Eclipse IDE is the leading development environment for Java with a market share of approximately 65%. but ac...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.