mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-24 10:01:38 +00:00
tweak order of string functions / print functions
This commit is contained in:
parent
35bd796a8e
commit
acc52c21e1
@ -93,21 +93,22 @@ ascii("This is a string")[1]
|
|||||||
# Julia indexes from 1
|
# Julia indexes from 1
|
||||||
# Otherwise, iterating over strings is recommended (map, for loops, etc).
|
# Otherwise, iterating over strings is recommended (map, for loops, etc).
|
||||||
|
|
||||||
|
# String can be compared lexicographically
|
||||||
|
"good" > "bye" # => true
|
||||||
|
"good" == "good" # => true
|
||||||
|
"1 + 2 = 3" == "1 + 2 = $(1 + 2)" # => true
|
||||||
|
|
||||||
# $ can be used for string interpolation:
|
# $ can be used for string interpolation:
|
||||||
"2 + 2 = $(2 + 2)" # => "2 + 2 = 4"
|
"2 + 2 = $(2 + 2)" # => "2 + 2 = 4"
|
||||||
# You can put any Julia expression inside the parentheses.
|
# You can put any Julia expression inside the parentheses.
|
||||||
|
|
||||||
|
# Printing is easy
|
||||||
|
println("I'm Julia. Nice to meet you!") # => I'm Julia. Nice to meet you!
|
||||||
|
|
||||||
# Another way to format strings is the printf macro from the stdlib Printf.
|
# Another way to format strings is the printf macro from the stdlib Printf.
|
||||||
using Printf
|
using Printf
|
||||||
@printf "%d is less than %f\n" 4.5 5.3 # => 5 is less than 5.300000
|
@printf "%d is less than %f\n" 4.5 5.3 # => 5 is less than 5.300000
|
||||||
|
|
||||||
# Printing is easy
|
|
||||||
println("I'm Julia. Nice to meet you!") # => I'm Julia. Nice to meet you!
|
|
||||||
|
|
||||||
# String can be compared lexicographically
|
|
||||||
"good" > "bye" # => true
|
|
||||||
"good" == "good" # => true
|
|
||||||
"1 + 2 = 3" == "1 + 2 = $(1 + 2)" # => true
|
|
||||||
|
|
||||||
####################################################
|
####################################################
|
||||||
## 2. Variables and Collections
|
## 2. Variables and Collections
|
||||||
|
Loading…
Reference in New Issue
Block a user