Skip to content

Instantly share code, notes, and snippets.

@ngerakines
Created July 18, 2009 23:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ngerakines/149735 to your computer and use it in GitHub Desktop.
Save ngerakines/149735 to your computer and use it in GitHub Desktop.
$ erlc nick.erl && erlc vanessa.erl
1> Me = nick:new("Mountain View", "CA").
{nick,"Mountain View","CA"}
2> Me:city().
nick:city/0 -> "Mountain View"
ok
3> Me:state().
nick:state/0 -> "CA"
ok
4> Vanessa = vanessa:new("Mountain View", "CA").
{vanessa,{nick,"Mountain View","CA"},"Mountain View","CA"}
5> Vanessa:city().
child:city/0 -> "Mountain View"
ok
6> Vanessa:state().
nick:state/0 -> "CA"
ok
7>
-module(nick, [City, State]).
-export([city/0, state/0]).
state() ->
io:format("nick:state/0 -> ~p~n", [State]).
city() ->
io:format("nick:city/0 -> ~p ~n", [City]).
-module(vanessa, [City, State]).
-extends(nick).
-export([city/0]).
city() ->
io:format("child:city/0 -> ~p ~n", [City]).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment