This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Use another github account in a certain folder | |
| # Credit: http://suguru03.hatenablog.com/entry/2018/01/26/162826 (https://github.com/suguru03) | |
| # | |
| # Note: This requires installing direnv, I used homebrew for the installation | |
| # | |
| # Suppose for a certain github account, a new SSH key "id_rsa_xxx" was created and added in Github | |
| # Create a .envrc file in the folder you want to use this account with the following line: | |
| export GIT_SSH_COMMAND="ssh -i ~/.ssh/id_rsa_xxx" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [core] | |
| excludesfile = /Users/01123805/.gitignore_global | |
| [diff] | |
| tool = "sourcetree" | |
| [difftool] | |
| prompt = true | |
| [difftool "sourcetree"] | |
| cmd = /Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" | |
| [mergetool "sourcetree"] | |
| cmd = /Applications/Sourcetree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Compiled source # | |
| ################### | |
| *.com | |
| *.class | |
| *.dll | |
| *.exe | |
| *.o | |
| *.so | |
| # Packages # |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // The parent class Shape | |
| class Shape { | |
| var className: String = "Shape" | |
| var numOfSides: Int = 0 | |
| init(numOfSides: Int) { | |
| self.numOfSides = numOfSides | |
| } | |
| func simpleDescription() -> String { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Talkie { | |
| var words: String = "I talk to others." { | |
| willSet { | |
| print("Words are going to be changed to: \(newValue)") | |
| } | |
| didSet { | |
| print("Words are changed to: \(words)") | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // class with getter setter | |
| class EquilateralTriangle { | |
| private var sideLength: Double = 0 //a private property that can only be set at instantiation | |
| init(sideLength: Double) { | |
| self.sideLength = sideLength | |
| } | |
| var perimeter: Double { | |
| get { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Class with init | |
| class MyClassWithInit { | |
| var myProperty: String | |
| var myOtherProperty: Int | |
| init(myProperty: String, otherProperty: Int) { | |
| self.myProperty = myProperty // Here you need "self" only because the property name is the same as the parameter name | |
| myOtherProperty = otherProperty // See, here you don't need "self" | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // To instantiate an object from MyClass | |
| let myObj = MyClass() | |
| myObj.myProperty // 0 | |
| myObj.myMethod() // 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // To declare a class | |
| class MyClass { | |
| var myProperty = 0 | |
| func myMethod() { | |
| return myProperty | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Closure examples | |
| (6) Access by index | |
| */ | |
| let numbers = [15, 23, 2, 9, 16] | |
| let reverseSorted = numbers.sorted { $0 > $1 } | |
| /* | |
| The value of reverseSorted: | |
| [23, 16, 15, 9, 2] | |
| */ |