Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include "person.h"
int main(int argc, const char *argv[])
{
person_t james = {"James", "Newton", 21};
person_print(james);
return 0;
}
require './person'
class James
include Person
def initialize(first_name, last_name, age)
@first_name = first_name
@last_name = last_name
@age = age
end
def old_enough_to_drink?
@age > 18
end
end
james = James.new('James', 'Newton', 21)
james.full_name #=> "James Newton"
james.old_enough_to_drink? #=> true
#include "person.h"
void person_print(person_t person)
{
printf("Name: %s %s\n", person.first_name, person.last_name);
printf("Age: %i\n", person.age);
}
#include <stdio.h>
typedef struct {
char *first_name;
char *last_name;
int age;
} person_t;
extern void person_print(person_t person);
module Person
def full_name
"#{@first_name} #{@last_name}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment