mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-04-27 15:43:58 +00:00
change String to AbstractString as per 0.4 spec
This commit is contained in:
parent
d8a1c0cf6a
commit
77f0219cc6
@ -78,7 +78,7 @@ false
|
|||||||
1 < 2 < 3 # => true
|
1 < 2 < 3 # => true
|
||||||
2 < 3 < 2 # => false
|
2 < 3 < 2 # => false
|
||||||
|
|
||||||
# Strings are created with "
|
# AbstractStrings are created with "
|
||||||
"This is a string."
|
"This is a string."
|
||||||
|
|
||||||
# Character literals are written with '
|
# Character literals are written with '
|
||||||
@ -314,7 +314,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
# For loops iterate over iterables.
|
# For loops iterate over iterables.
|
||||||
# Iterable types include Range, Array, Set, Dict, and String.
|
# Iterable types include Range, Array, Set, Dict, and AbstractString.
|
||||||
for animal=["dog", "cat", "mouse"]
|
for animal=["dog", "cat", "mouse"]
|
||||||
println("$animal is a mammal")
|
println("$animal is a mammal")
|
||||||
# You can use $ to interpolate variables or expression into strings
|
# You can use $ to interpolate variables or expression into strings
|
||||||
@ -550,13 +550,13 @@ super(Any) # => Any
|
|||||||
# <: is the subtyping operator
|
# <: is the subtyping operator
|
||||||
type Lion <: Cat # Lion is a subtype of Cat
|
type Lion <: Cat # Lion is a subtype of Cat
|
||||||
mane_color
|
mane_color
|
||||||
roar::String
|
roar::AbstractString
|
||||||
end
|
end
|
||||||
|
|
||||||
# You can define more constructors for your type
|
# You can define more constructors for your type
|
||||||
# Just define a function of the same name as the type
|
# Just define a function of the same name as the type
|
||||||
# and call an existing constructor to get a value of the correct type
|
# and call an existing constructor to get a value of the correct type
|
||||||
Lion(roar::String) = Lion("green",roar)
|
Lion(roar::AbstractString) = Lion("green",roar)
|
||||||
# This is an outer constructor because it's outside the type definition
|
# This is an outer constructor because it's outside the type definition
|
||||||
|
|
||||||
type Panther <: Cat # Panther is also a subtype of Cat
|
type Panther <: Cat # Panther is also a subtype of Cat
|
||||||
|
Loading…
Reference in New Issue
Block a user