文字 (
注意事項
プログラミング注意事項
例
| 例 | |
{String "This String is created with ", 3, " arguments"}
|
| 新しい |
| n 個の c の文字列を返します。 |
| 文字列に対して繰り返し処理を実行するコンテナである |
| self 内の文字数。 |
| self と、指定された |
| self 内の指定された文字を返します。 |
| self の指定された部分文字列を返します。 |
| self と同一 (==) の |
n 個の c の文字列を返します。
文字列に対して繰り返し処理を実行するコンテナである
注意事項
self 内の文字数。
戻り値
説明
例
| 例 | |
{value
|| Declare and initialize a read-only string
let s:String = "Hello World!"
|| Output a message that includes the return value of
|| a call to "size".
|| Note that you must use "value" to display the value
|| of "s.size", rather than the text "s.size".
{text There are {value s.size} characters in the string.}
}
|
| 例 | |
{value
|| Declare and initialize a writable string.
let sb:StringBuf = {StringBuf "Hello World!"}
|| Set the size of the string to 5 characters.
|| The string should now contain only the first five
|| characters, "Hello".
set sb.size = 5
|| Output a message that includes the new string
{text If {monospace size} is set to 5, the string
becomes: {value sb}}
}
|
| 例 | |
{value
|| Declare and initialize a writable string.
let sb:StringBuf = {StringBuf "Hello World!"}
|| Set the size of the string to 20 characters.
|| The string should now have 8 characters
|| with the Unicode value 0000 at the end.
set sb.size = 20
|| Output a message that includes the new string.
{text Then, if {monospace size} is set to 20, the string
becomes: {value sb}}
}
|
注意事項
self と、指定された
戻り値
例
| 例 | |
![]() | |
{value
|| Declare and initialize two strings
let s1:String = "Hello World!"
let s2:String = "hello world!"
|| Display the strings.
{text
String 1: {value s1}
{br}String 2: {value s2}
|| Test if the two strings are equal and display
|| an appropriate message.
{if {s1.equal? s2} then
{text The strings are equal.}
else
{text The strings are NOT equal.}
}
|| Test if the two strings are equal, this time
|| ignoring case, and display an appropriate message.
But, if you ignore case,
{if {s1.equal? s2, ignore-case? = true} then
{text they are equal.}
else
{text they are NOT equal.}
}
}
}
|
self 内の指定された文字を返します。
例外のスロー
index が範囲外の場合は例
| 例 | |
{value
|| Declare and initialize a string.
let s:String = "Hello World!"
|| Display the string and return the
|| character at position 7.
|| Remember that the leftmost position
|| is 0 (zero).
{text {value s}
{br}The character at position 7 is {s.get 7}.}
}
|
注意事項
self の指定された部分文字列を返します。
戻り値
注意事項
例
| 例 | |
{value
|| Declare and initialize s1 (the original string).
let s1:String = "Hello World!"
|| Initialize s2 with a substring of s1. The
|| substring begins at position 6 and is 5
|| characters long ("World").
|| Remember that the leftmost position
|| is 0 (zero).
let s2:String = {s1.substr 6, 5}
|| Display the contents of s2.
{value s2}
}
|
注意事項
self と同一 (==) の
戻り値
例
| 例 | |
{value
|| Define and initialize a StringBuf.
let sb:StringBuf = {StringBuf "Hello World!"}
|| Convert the StringBuf to a String.
let s:String = {sb.to-String}
|| Display the contents of the String.
{value s}
}
|