[MOD] small changes
This commit is contained in:
parent
f3c835d7c2
commit
27cba34e93
|
@ -1,22 +0,0 @@
|
||||||
# Conversion
|
|
||||||
function foobar(a,b)
|
|
||||||
x::Int8 = a
|
|
||||||
y::Int8 = b
|
|
||||||
x+y
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
println(isa(2,Float64))
|
|
||||||
println(isa(Int8,Type{Int8}))
|
|
||||||
println(convert(Int8,4))
|
|
||||||
Base.convert(::Type{Int8},x::String) = parse(Int8,x)
|
|
||||||
|
|
||||||
println(1+2.0+Int8(3))
|
|
||||||
println(typeof(1+2.0+Int8(3)))
|
|
||||||
println(promote(1,2.0,Int8(3)))
|
|
||||||
|
|
||||||
a = (3,2)
|
|
||||||
|
|
||||||
println(+(a...)) # Tuple unpacking notation
|
|
||||||
|
|
||||||
# @edit 2 + 4.0 macro to get
|
|
31
NewType.jl
31
NewType.jl
|
@ -1,31 +0,0 @@
|
||||||
abstract Shape
|
|
||||||
|
|
||||||
type Circle <: Shape
|
|
||||||
x::Float64
|
|
||||||
y::Float64
|
|
||||||
radius::Float64
|
|
||||||
end
|
|
||||||
|
|
||||||
getposition(c::Circle) = (c.x,c.y)
|
|
||||||
|
|
||||||
function setposition(c::Circle,x,y)
|
|
||||||
c.x = x
|
|
||||||
c.y = y
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
type Rectangle <: Shape
|
|
||||||
x:: Float64
|
|
||||||
y::Float64
|
|
||||||
width::Float64
|
|
||||||
height::Float64
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
type ShapeGroup <: Shape
|
|
||||||
members::Vector{Shape}
|
|
||||||
end
|
|
||||||
|
|
||||||
function group(shapes::Shape...)
|
|
||||||
ShapeGroup(collect(shapes))
|
|
||||||
end
|
|
|
@ -1,11 +0,0 @@
|
||||||
telltype(x) = "Unknown Type"
|
|
||||||
telltype(x::Integer) = "Integer Type"
|
|
||||||
telltype(::AbstractFloat) = "Floatingpoint Type"
|
|
||||||
telltype(::Int64) = "64 Bytes Integer"
|
|
||||||
counargs(a) = "one"
|
|
||||||
counargs(a,b) = "two"
|
|
||||||
counargs(a,b,c) = "three"
|
|
||||||
foo(a,b) = "Two variables"
|
|
||||||
foo(a::Integer,b::Integer) = "Two integers"
|
|
||||||
foo(a::Integer,b::AbstractFloat) = "An integer and a float"
|
|
||||||
foo(a::AbstractFloat,b::Integer) = "An float and an integer"
|
|
Loading…
Reference in New Issue