Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dpsanders/8ea7bde9d2a549c97274 to your computer and use it in GitHub Desktop.
Save dpsanders/8ea7bde9d2a549c97274 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"move! (generic function with 2 methods)"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"abstract Person\n",
"\n",
"type Adult <: Person\n",
" age::Int\n",
" height::Float64\n",
" position::Int\n",
"end\n",
"\n",
"type Child <: Person\n",
" age::Int\n",
" height::Float64\n",
" position::Int\n",
" at_school::Bool\n",
"end\n",
"\n",
"type Bad <: Person\n",
" age::Int\n",
"end\n",
"\n",
"function move!(p::Person)\n",
" p.position += 1\n",
"end\n",
"\n",
"function move!(c::Child)\n",
" p.position += 1\n",
" p.at_school = !p.at_school\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 0.3.11-pre",
"language": "julia",
"name": "julia-0.3"
},
"language_info": {
"name": "julia",
"version": "0.3.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment