Skip to content

Instantly share code, notes, and snippets.

@aisk
Last active August 29, 2015 14:03
Show Gist options
  • Save aisk/1878a3664b40c7f0ae79 to your computer and use it in GitHub Desktop.
Save aisk/1878a3664b40c7f0ae79 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
struct Person {
char* name;
void (^say)(void);
};
struct Person *PersonNew(char *name) {
struct Person *self = malloc(sizeof(struct Person));
self->name = name;
self->say = ^ {
printf("Hello my name is %s\n", self->name);
};
return self;
}
int main() {
struct Person *jim = PersonNew("Jim Green");
jim->say();
free(jim);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment