Last active
August 29, 2015 14:04
-
-
Save tomasaschan/ea7781b2eaedccfef12a to your computer and use it in GitHub Desktop.
Importing and extending methods
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Baz | |
import Foo: bar | |
export Qux, bar | |
type Qux | |
x | |
end | |
bar(q::Qux) = bar(q.x) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include("Foo.jl") | |
include("Baz.jl") | |
using Foo | |
using Baz | |
println("After only one include:\n") | |
display(methods(bar)) | |
println("\n\nIncluding Baz.jl again...") | |
include("Baz.jl") | |
println("\nNow, after two includes:\n") | |
display(methods(bar)) | |
println() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Foo | |
export bar | |
function bar(x) | |
println(x+1) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment