This file contains 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
protocol Bar { | |
var baz: Int { get } | |
} | |
func foo() -> Bar { | |
class BarImpl: Bar { | |
let baz: Int | |
init(_ value: Int) { | |
baz = value |
This file contains 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 foo() -> (baz: Int, buck: String) { | |
return (baz: 3, buck: "Shitty titties") | |
} | |
let val = foo() | |
let baz = val.baz |
This file contains 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
void foo() { | |
__block int baz = 3; | |
int (^getBaz)(void) = ^{ | |
return baz; | |
}; | |
void (^setBaz)(int newValue) = ^(int newValue){ | |
baz = newValue; | |
}; |
This file contains 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
struct FooReturn { | |
int (^getBaz)(void); | |
void (^setBaz)(int newValue); | |
}; | |
struct FooReturn foo(int initialBazValue) { | |
__block int baz = initialBazValue; | |
int (^getBaz)(void) = ^{ | |
return baz; |
This file contains 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 foo(_ initialBazValue: Int) -> (getBaz: () -> Int, setBaz: (Int) -> Void) { | |
var baz = initialBazValue | |
let getBaz = { baz } | |
let setBaz = { baz = $0 } | |
return ( | |
getBaz: getBaz, | |
setBaz: setBaz | |
) |
This file contains 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 <tuple> | |
auto foo(int initialBaz) { | |
int baz = initialBaz; | |
auto getBaz = [&] { | |
return baz; | |
}; | |
auto setBaz = [&](int newValue) { |
This file contains 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
auto foo() { | |
class Bar { | |
public: | |
int baz; | |
}; | |
Bar ret; | |
ret.baz = 3; | |
return ret; |
This file contains 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
function foo(initialBaz) { | |
return { | |
baz: initialBaz, | |
getBaz() { | |
return this.baz | |
}, | |
setBaz(newValue) { | |
this.baz = newValue | |
} | |
} |
This file contains 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 <stdlib.h> | |
typedef struct { | |
int someInt; | |
char* someString; // and other captured objects | |
} Captures; | |
int addingStuff(Captures* captures, int param) { | |
return captures->someInt + param; | |
} |
This file contains 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 Foundation | |
import Cocoa | |
/* | |
SETUP | |
*/ | |
let payload = """ | |
{ | |
"things": [ |