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
| __block int variable = 1; | |
| int anotherVariable = 2; | |
| void (block^)() = ^{ | |
| variable++; // actually modifying variable | |
| anotherVariable++; // modifying a copy | |
| } |
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
| int nonModifiable = 42; | |
| int modifiable = 23; | |
| auto myLambda = [=, &modifiable]() mutable { modifiable++; nonModifiable++; }; | |
| myLambda(); // modifiable == 24, nonModifiable == 42 |
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
| std::shared_ptr<GameObject> gameObject { std::make_shared<GameObject>("Bomb") }; | |
| cocos2d::CCLabelTTF *myLabel = cocos2d::CCLabelTTF::create("Explode!", "Arial", 30.0f); | |
| auto myLambda = [gameObject]() | |
| { | |
| if (gameObject.use_count() > 1) | |
| { | |
| gameObject->explode(); | |
| } | |
| }); |
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
| func CopyFile(dstName, srcName string) (written int64, err error) { | |
| src, err := os.Open(srcName) | |
| if err != nil { | |
| return | |
| } | |
| defer src.Close() | |
| dst, err := os.Create(dstName) | |
| if err != nil { | |
| return |
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
| func b() { | |
| for i := 0; i < 4; i++ { | |
| defer fmt.Print(i) | |
| } | |
| } |
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
| #include <iostream> | |
| #include <functional> | |
| #include <stack> | |
| class Deferrer | |
| { | |
| public: | |
| Deferrer() {} | |
| ~Deferrer() { callAll(); } |
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 FirstComponent(object): | |
| def __init__(self, parent): | |
| object.__init__() | |
| parent.someFunc = self.someFunc | |
| def someFunc(self): | |
| return 42 | |
| class GameObject(object): | |
| def __init__(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
| class Base | |
| { | |
| public: | |
| Base() {} | |
| virtual ~Base() {} | |
| }; | |
| class NotCopyable | |
| { | |
| public: |
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
| import sys | |
| import telnetlib | |
| if __name__ == "__main__": | |
| mail = { | |
| "from": sys.argv[1], | |
| "to": sys.argv[2], | |
| "subject": sys.argv[3], | |
| "msg": sys.argv[4] |
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
| from leap.soledad import Soledad | |
| import logging | |
| level = logging.DEBUG | |
| logger = logging.getLogger(name='leap') | |
| logger.setLevel(level) | |
| console = logging.StreamHandler() | |
| console.setLevel(level) |
OlderNewer