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
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
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
__block int variable = 1; | |
int anotherVariable = 2; | |
void (block^)() = ^{ | |
variable++; // actually modifying variable | |
anotherVariable++; // modifying a copy | |
} |
NewerOlder