[Julia] 02. Strings


Strings
  • How to get a string
  • String interpolation
  • String concatenation
  • How to get a string
    「」または「」を使用してstringを入力できます.
    s1 = "I am a string."
    "I am a string."
    s2 = """I am also a string."""
    "I am also a string."
    "single quotation 안에는 "single quotation"를 넣을 수 없다."
    syntax: cannot juxtapose string literal
    """triple quotation 안에는 "single quotation"을 넣을 수 있다. """
    三重オファーには「単オファー」を加えることができます.
    「」は文字を定義します.
    typeof('a')
    Char
    'string을 표현할 수 없다.'
    syntax: character literal contains multiple characters
    String interpolation
    stringに変数を追加し、式に$を使用します.
    name = "Jane"
    num_fingers = 10
    num_toes = 10
    10
    println("hello, my name is $name.")
    println("I have $num_fingers fingers and $num_toes toes.")
    hello, my name is Jane.
    I have 10 fingers and 10 toes.
    println("That is $(num_fingers + num_toes) digits in all!!")
    That is 20 digits in all!!
    String concatenation
    string()または*を使用して文字列を組み合わせることができます.
    s3 = "How many cats "
    s4 = "is too many cats?"
    😺 = 10
    10
    string(s3, s4)
    "How many cats is too many cats?"
    string("I don't know, but ", 😺, " is too few.")
    "I don't know, but 10 is too few."
    s3 * s4
    "How many cats is too many cats?"
    a = 3
    b = 4
    4
    c = "$a + $b"
    "3 + 4"
    d = "$(a + b)"
    "7"