Skip to content

Instantly share code, notes, and snippets.

@jameswritescode
Created February 21, 2014 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jameswritescode/9130475 to your computer and use it in GitHub Desktop.
Save jameswritescode/9130475 to your computer and use it in GitHub Desktop.
#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