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 reachf 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:
- For a value
xof typeTor*TwhereTis not an interface type,x.fdenotes the field or method at the shallowest depth inTwhere there is such anf. If there is not exactly onefwith shallowest depth, the selector expression is illegal. - For a variable
xof typeIwhereIis an interface type,x.fdenotes the actual method with namefof the value assigned tox. If there is no method with namefin the method set ofI, the selector expression is illegal. - In all other cases,
x.fis illegal. - If
xis of pointer type and has the valuenilandx.fdenotes a struct field, assigning to or evaluatingx.fcauses a run-time panic. - If
xis of interface type and has the valuenil, calling or evaluating the methodx.fcauses 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
go语言的selector的更多相关文章
- objective-c中的@selector()和 c /c++的函数指针
先看tomcat里用到的代码: //然后开始动画 //把图片放到animationImages,接受数组参数 self.tom.animationImages = arrayImage; //设置时间 ...
- R语言爬虫初尝试-基于RVEST包学习
注意:这文章是2月份写的,拉勾网早改版了,代码已经失效了,大家意思意思就好,主要看代码的使用方法吧.. 最近一直在用且有维护的另一个爬虫是KINDLE 特价书爬虫,blog地址见此: http://w ...
- 黑马程序员——OC语言基础语法 面向对象的思想
Java培训.Android培训.iOS培训..Net培训.期待与您交流! (以下内容是对黑马苹果入学视频的个人知识点总结)(一)基础语法 1)关键字 @interface.@implementati ...
- 【转】浅思OC的语言特性
算了算,学习IOS已经有一段时间了.今天花了点时间思考一下OC的语言特性,让自己的心不要那么浮躁,注重基础,回归本源. OC做为一门面向对象语言,自然具有面向对象的语言特性,如封装.继承.多态.他具有 ...
- [Java面试九]脚本语言知识总结.
核心内容概述 1.JavaScript加强,涉及到ECMAScript语法.BOM对象.DOM对象以及事件. 2.Ajax传统编程. 3.jQuery框架,九种选择器为核心学习内容 4.JQuery ...
- XML学习笔记6——XPath语言
在上一篇笔记的结尾,我们接触到了两个用于选择XML文档中特定范围的元素<selector>和<field>,这两个元素的取值都是XPath表达式,那么,什么是XPath呢?简单 ...
- 如何设置unobtrusive的语言包
场景:网站是用的validate.unotrusive.js验证的,网站的语言已经切换到繁体了,但是提示语言还是英文. 环境:asp.net mvc4,jquery.validate.unotrusi ...
- OC语言description方法和sel
OC语言description方法和sel 一.description方法 Description方法包括类方法和对象方法.(NSObject类所包含) (一)基本知识 -description(对象 ...
- OC语言-04-OC语言-核心语法
一.点语法 1> 基本使用 点语法本质上是set方法/get方法的调用 2> 使用注意 若出现在赋值操作符的右边,在执行时会转换成get方法 若出现在赋值操作符的左边,在执行时会转换成se ...
随机推荐
- 关于使用TP-Link桥接小米路由器
家里因为有个小卧室,小卧室的写字台上面放了一台台式电脑,而我又不想用台式电脑牵一条长线到客厅的网口或者路由器上面,因为太麻烦,所以我使用了TPLink的无线USB插在了我的主机USB上,略去TPLIN ...
- Percona Toolkit 使用
安装 percona-toolkit perl Makefile.PL make make test make install 默认安装到 /usr/local/bin 目录下 可能需要 DBI-1. ...
- Allegro 快捷键设置
一.快捷键设置 Allegro可以通过修改env文件来设置快捷键,这对从其它软件如AD或PADS迁移过来的用户来说,可以沿用以前的操作习惯,还是很有意义的. Allegro的变量文件一共有2个:一个是 ...
- Kafka深度解析,众人推荐,精彩好文!
作者: Jason Guo 背景介绍 Kafka简介 Kafka是一种分布式的,基于发布/订阅的消息系统.主要设计目标如下: 以时间复杂度为O(1)的方式提供消息持久化能力,并保证即使对TB级以上数据 ...
- Entity Framework 学习笔记
1.自定义数据库链接字符串上下文 public class PetDbContext : DbContext { public PetDbContext() : base("name=Dem ...
- http://blog.csdn.net/krislight/article/details/9391455
http://blog.csdn.net/krislight/article/details/9391455
- [DFNews] Cellebrite UFED Logical/Physical Analyzer 3.8.1 维护性更新
Maintenance Release Cellebrite has released a maintenance version of UFED Physical / Log ...
- 定位form光标行
In AX2009 if you call the research() method on a form passing true, the cursor position within a gri ...
- C++ 全局变量、局部变量、静态全局变量、静态局部变量的区别
全局变量.局部变量.静态全局变量.静态局部变量的区别 C++变量根据定义的位置的不同的生命周期,具有不同的作用域,作用域可分为6种:全局作用域,局部作用域,语句作用域,类作用域,命名空间作用域和文件作 ...
- Android的各种Drawable 讲解 大全
Android把可绘制的对象抽象为Drawable,不同的图形图像资源就代表着不同的drawable类型.Android FrameWork提供了一些具体的Drawable实现,通常在代码中都不会直接 ...