拥有AnyClass类型的变量,是否可以知道该类型是否是另一种类型的扩展或实现?
例如:
var aClass: AnyClass = UIButton.self
// assuming a fictional operator "isOfType"
// Both UIButton and UILabel are subclasses of UIView
aClass isOfType UIButton // true
aClass isOfType UIView // true
aClass isOfType UILabel // false
Run Code Online (Sandbox Code Playgroud)
一种可能的方法是创建一个实例,但创建这样的实例可能并不总是令人满意的:
var aClass: AnyClass = UIButton.self
let buttonClass = aClass as? UIButton.Type
var aButton: AnyObject = buttonClass!()
aButton is UIButton // true
aButton is UIView // true
aButton is UILabel // false
Run Code Online (Sandbox Code Playgroud)
还有其他方法可以检查AnyClass是否包含扩展另一种类型的类型吗?
创建名称与远程分支名称匹配的分支时,push和pull的配置设置不同.
拥有当前的远程分支:
$ git branch -r
origin/HEAD -> origin/master
origin/master
origin/someBranch
Run Code Online (Sandbox Code Playgroud)
并创建一些跟踪远程分支的本地分支:
$ git branch someBranch origin/someBranch
Branch someBranch set up to track remote branch someBranch from origin.
$ git branch someOtherBranch origin/someBranch
Branch someOtherBranch set up to track remote branch someBranch from origin.
Run Code Online (Sandbox Code Playgroud)
检查跟踪和上游信息:
$ git remote show origin
* remote origin
Fetch URL: git@github.somewhere.com:maic/repo.git
Push URL: git@github.somewhere.com:maic/repo.git
HEAD branch: master
Remote branches:
master tracked
someBranch tracked
Local branches configured for 'git pull':
master merges with remote master
someBranch …Run Code Online (Sandbox Code Playgroud) 在bash中使用getopt的通常示例如下
args=`getopt abo: $*`
errcode=$?
set -- $args
Run Code Online (Sandbox Code Playgroud)
最后一行实现了什么?
在我的git repo中,结果ls -a是:
.fileInFirstCommit.un~
.fileInSecondCommit.un~
.git
fileInFirstCommit
fileInFirstCommit~
fileInSecondCommit
fileInSecondCommit~
Run Code Online (Sandbox Code Playgroud)
什么是这些.un~文件?