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 ...
随机推荐
- Python的第六天
常用模块的学习 一.time & datetime模块 时间相关的操作,时间有三种表示方式: 时间戳 1970年1月1日之后的秒,即:time.time() 格式化 ...
- Hibernate5.2之反向工程
Hibernate5.2之反向工程 一.描述 可能很多人在使用Hibernate进行项目开发 ...
- Zedboard安装桌面系统ubuntu及opencv(1)
最近一直在搞板子,想帮Zedboard安装一个opencv谁知道困难重重,而且网络几乎没有任何资料可以参考,只有陆佳华的<嵌入式软硬件协同设计实战指南>可以参考. 但是这本书讲得不清不楚, ...
- php 对url 操作类:url拼接、get获取页面、post获取页面(带传参)
/* * @brief url封装类,将常用的url请求操作封装在一起 * */ class URL{ private $error; public function __construct(){ $ ...
- 一次Redis的使用Bug记录(exec)
博主在一次项目中,使用了工具类中的Redis类,因为该Redis没有封装管道pipeline和exec命令,所以就大笔一挥来了一段__call; 代码如下(其中$this->_connect() ...
- IIS发布问题汇总
1.未能加载文件或程序集“System.Data.SQLite” 在IIS界面选择应用程序池->选择所使用的.net 版本->高级设置->将"使用32位应用程序" ...
- 动态主机配置协议(DHCP)如何启动和关闭
启动方法: 开始-->运行-->cmd-->回车-->net start dhcp 关闭方法: 开始-->运行-->cmd-->回车-->net sto ...
- 利用Oracle自带的impdp和expdp进行简单备份
目前有个这样的需求,每天晚上23点将生产库的数据备份到备份机器上,第二天备份机器的数据库可以直接使用,数据是昨天生产库的数据.(生产数据目前不多,全部数据不超过3000w条). 由于没有接触过高深的O ...
- expr 命令
求表达式变量的值.expr 命令读入 Expression 参数,计算它的值,然后将结果写入到标准输出. 用法:expr Expression Expression 参数规则: 用空格隔开每个项. 用 ...
- xcode 工具学习笔记
1. 快速打开辅助界面 快捷键:使用Option + 单击文件 2. 辅助编辑器更多打开方式 快捷键: Option+shift +单击文件 3. tab页面快捷键 快捷键: Co ...