Last active
September 13, 2015 04:23
-
-
Save bicycle1885/c75fcd011f822fb94818 to your computer and use it in GitHub Desktop.
New v0.4 features.
This file contains 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
type Foo | |
x | |
Foo(x::Int) = new(x) | |
end | |
Base.convert(::Type{Foo}, x::Integer) = Foo(convert(Int, x)) | |
@show Foo(1) # ok both on v0.3 and v0.4 | |
@show Foo(0x01) # ok on v0.4, but not on v0.3 |
This file contains 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
""" | |
Point type. | |
This is a type to represent a point in 3D Cartesian coordinate system. | |
Fields: | |
* `x`: coordinate of X axis. | |
* `y`: coordinate of Y axis. | |
* `z`: coordinate of Z axis. | |
""" | |
type Point | |
x::Float64 | |
y::Float64 | |
z::Float64 | |
end | |
"Enclidean distance from the origin." | |
function distance(p::Point) | |
sqrt(p.x^2 + p.y^2 + p.z^2) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment