ソースコードのコメントから自動生成されています。
重要な注意事項
プリミティブメソッドのオーバーライド
Rustプリミティブとして実装されたメソッドは、同名のSmalltalkメソッドを定義することでオーバーライドできます。 ユーザー定義メソッドがプリミティブより優先されます。
"プリミティブメソッドをオーバーライド"
String >> size
^ 999
!
'hello' size. "=> 999 (ユーザー定義メソッドが呼ばれる)"
注意: プリミティブをオーバーライドすると、最適化されたRust実装がバイパスされるため、 パフォーマンスに影響します。
文字列リテラル
文字列はシングルクォートで書き、中のクォートは 2 つ重ねます('it''s')。ANSI Smalltalk と同じです。
LST はさらに次のバックスラッシュエスケープを解釈します(LST 独自拡張、Unix の伝統との親和性のため): \n(LF)、\r(CR)、\t(タブ)、\0(NUL)、\\(バックスラッシュ)。
それ以外のバックスラッシュはそのまま残るので、正規表現が自然に書けます。'\d+' は 3 文字です。
\' はありません。閉じクォートの前のバックスラッシュは単なるバックスラッシュです('\' は 1 文字)。
Windows のパスは / か 2 重のバックスラッシュで書いてください。'C:\temp' はタブを含み、'C:/temp' と 'C:\\temp' は含みません。
バックスラッシュ自体にマッチする正規表現は '\\\\' です。
Grammar の /regex/ の中では \\n と書きます(/[^\\n]*/)。実際の改行は規則を終わらせてしまうためです。regexMatches: などの正規表現系メッセージは '[^\n]*' をそのまま受け取ります。
目次
組み込みクラス
- Aes class
- Array
- Array class
- Base64 class
- Block
- ByteArray
- ByteArray class
- Character
- ChildProcess
- ChildProcess class
- Csv class
- CsvReader
- DateTime class
- Dict
- Dict class
- Directory class
- Env class
- File class
- Float
- Float class
- Grammar
- Grammar class
- Hmac class
- Http class
- Integer
- Interval
- Interval class
- Json class
- Object
- OrderedCollection
- OrderedCollection class
- ParseTree
- Path class
- Point
- Process class
- Random class
- Set
- Set class
- Sha2 class
- Sqlite
- Sqlite class
- Stdin class
- String
- StringStream
- StringStream class
- System
- System class
- Tcp class
- TcpListener
- TcpListener class
- TcpStream
- Template class
- Time class
- Toml class
- WriteHandle
- WriteHandle class
- Yaml class
標準ライブラリ
- Ansi class
- Array
- Array class
- ByteArray
- CLI.ArgParser
- CLI.ParseResult
- Collection
- Collection class
- Core.Association class
- Core.Block
- Core.Boolean
- Core.Exception class
- Core.ExceptionSet
- Core.Number
- Core.Object
- Core.Object class
- Core.Path class
- Core.String
- Core.String class
- Core.StringStream
- Core.Time class
- Core.WriteHandle class
- Dictionary
- Env class
- Float
- Integer
- Interval
- Maybe class
- Number
- OrderedCollection
- Point
- Shell.Sh class
- String
- String class
- Text.TablePrinter
組み込みクラス
Aes class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
encrypt:key: | Primitive | plaintext String - text to encrypt, key String - 256-bit key as 64-char hex string (use Sha2 sha256: to derive) | String - hex-encoded nonce + ciphertext + tag; a key that is not 64 hex digits raises an Error | Aes encrypt: 'hello' key: (Sha2 sha256: 'secret') |
decrypt:key: | Primitive | encrypted String - hex string from encrypt:key:, key String - same 256-bit key used for encryption | String - decrypted plaintext; a wrong key, altered or malformed ciphertext, an invalid key, or a plaintext that is not UTF-8 raises an Error saying which | Aes decrypt: encrypted key: (Sha2 sha256: 'secret') |
Array
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
size | Primitive | - | Integer - number of elements | #(1 2 3) size "=> 3" |
at: | Primitive | index Integer - 1-based index | Any - element at index; an index outside the array raises an Error | #(10 20 30) at: 2 "=> 20" |
at:put: | Primitive | index Integer - 1-based index, value Any - value to store | Any - the stored value; an index outside the array raises an Error | arr at: 1 put: 'hello' |
first | Primitive | - | Any - first element, or nil if empty | #(10 20 30) first "=> 10" |
last | Primitive | - | Any - last element, or nil if empty | #(10 20 30) last "=> 30" |
add: | Primitive | value Any - value to append | self | arr add: 42 |
includes: | Primitive | value Any - value to search for | Boolean - true if found | #(1 2 3) includes: 2 "=> true" |
sort | Primitive | - | Array - new sorted array | #(3 1 2) sort "=> #(1 2 3)" |
indexOf: | Primitive | value Any - value to search for | Integer - 1-based index, or 0 if not found | #(10 20 30) indexOf: 20 "=> 2" |
join: | Primitive | separator String - separator between elements | String - joined string | #('a' 'b' 'c') join: '-' "=> 'a-b-c'" |
, | Primitive | other Array - array to append | Array - new concatenated array | #(1 2) , #(3 4) "=> #(1 2 3 4)" |
copyFrom:to: | Primitive | start Integer - 1-based start index, end Integer - 1-based end index (inclusive) | Array - new sliced array | #(10 20 30 40) copyFrom: 2 to: 3 "=> #(20 30)" |
asString | Primitive | - | String - string representation | #(1 2 3) asString "=> '#(1 2 3)'" |
sum | Primitive | - | Number - sum of all numeric elements | #(1 2 3 4 5) sum "=> 15" |
max | Primitive | - | Object - maximum element or nil if empty | #(3 1 4 1 5) max "=> 5" |
min | Primitive | - | Object - minimum element or nil if empty | #(3 1 4 1 5) min "=> 1" |
average | Primitive | - | Number - average of all numeric elements (0 if empty) | #(1 2 3 4 5) average "=> 3" |
sum | Primitive | - | Number - sum of all numeric elements | #(1 2 3 4 5) sum "=> 15" |
max | Primitive | - | Object - maximum element or nil if empty | #(3 1 4 1 5) max "=> 5" |
min | Primitive | - | Object - minimum element or nil if empty | #(3 1 4 1 5) min "=> 1" |
product | Primitive | - | Number - product of all numeric elements | #(1 2 3 4 5) product "=> 120" |
formatEach: | Primitive | template String - Mustache template string | Array - array of rendered strings; a template that does not compile, or an element that is not a Dictionary, raises an Error | { #{'name' -> 'Alice'}. #{'name' -> 'Bob'} } formatEach: 'Hello, {{name}}!' |
formatEach:join: | Primitive | template String - Mustache template string, separator String - separator between rendered strings | String - joined rendered strings; errors as for formatEach: | { #{'x' -> '1'}. #{'x' -> '2'} } formatEach: '{{x}}' join: ', ' |
average | Primitive | - | Number - average of all numeric elements (0 if empty) | #(1 2 3 4 5) average "=> 3" |
Array class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
new: | Primitive | size Integer - number of elements (all nil) | Array - new array of the given size | Array new: 3 "=> #(nil nil nil)" |
Base64 class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
encode: | Primitive | data String|ByteArray - data to encode | String - base64 encoded string | Base64 encode: 'Hello, World!' |
decode: | Primitive | string String - base64 string to decode | String|ByteArray - decoded data: a String when it is UTF-8 text, otherwise a ByteArray; invalid base64 raises an Error | Base64 decode: 'SGVsbG8sIFdvcmxkIQ==' |
Block
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
argumentCount | Primitive | - | Integer - the number of arguments the block takes (ANSI 5.4.1.1) | [:a :b | a + b] argumentCount "=> 2" |
ByteArray
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
at: | Primitive | index Integer - 1-based index | Integer - byte value (0-255); an index outside the array raises an Error | bytes at: 1 |
at:put: | Primitive | index Integer - 1-based index, value Integer - byte value 0-255, or a Character whose code point is 0-255; anything else raises an Error | Integer - stored value; an index outside the array raises an Error | bytes at: 1 put: 255 |
size | Primitive | - | Integer - number of bytes | bytes size |
asString | Primitive | - | String - UTF-8 string from bytes | bytes asString |
copyFrom:to: | Primitive | start Integer - 1-based start index, end Integer - 1-based end index (inclusive) | ByteArray - new sliced byte array | bytes copyFrom: 1 to: 10 |
ByteArray class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
new: | Primitive | size Integer - number of bytes | ByteArray - new byte array filled with zeros | ByteArray new: 10 |
fromString: | Primitive | string String - string to convert | ByteArray - UTF-8 bytes of string | ByteArray fromString: 'hello' |
Character
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
isLetter | Primitive | - | Boolean - true if alphabetic | $a isLetter "=> true" |
isDigit | Primitive | - | Boolean - true if numeric digit | $5 isDigit "=> true" |
isAlphanumeric | Primitive | - | Boolean - true if letter or digit | $a isAlphanumeric "=> true" |
isUppercase | Primitive | - | Boolean - true if uppercase letter | $A isUppercase "=> true" |
isLowercase | Primitive | - | Boolean - true if lowercase letter | $a isLowercase "=> true" |
isWhitespace | Primitive | - | Boolean - true if whitespace character | $ isWhitespace "=> true" |
asUppercase | Primitive | - | Character - uppercase version | $a asUppercase "=> $A" |
asLowercase | Primitive | - | Character - lowercase version | $A asLowercase "=> $a" |
asInteger | Primitive | - | Integer - Unicode code point | $A asInteger "=> 65" |
asString | Primitive | - | String - single-character string | $A asString "=> 'A'" |
= | Primitive | other Character - character to compare | Boolean - true if equal | $a = $a "=> true" |
< | Primitive | other Character - character to compare | Boolean - true if less than | $a < $b "=> true" |
<= | Primitive | other Character - character to compare | Boolean - true if less than or equal | $a <= $a "=> true" |
> | Primitive | other Character - character to compare | Boolean - true if greater than | $b > $a "=> true" |
>= | Primitive | other Character - character to compare | Boolean - true if greater than or equal | $a >= $a "=> true" |
ChildProcess
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
isFinished | Primitive | - | Boolean - true if the process has exited (does not block) | child isFinished |
exitCode | Primitive | - | Integer - waits for the process to finish and answers its exit code (128 + the signal number for a process a signal ended, Unix); any number of times | child exitCode |
wait | Primitive | - | String - waits for the process to finish and answers its stdout; any number of times (the same String). exitCode then answers the exit code | child wait |
ChildProcess class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
spawn:args: | Primitive | command String - command to spawn (not through a shell), args Array - the arguments, as for Process run:args: | ChildProcess - spawned process handle; its stdout is captured for wait, its stderr passes through to this process's stderr. A command that cannot be started raises an Error naming it and the OS reason | ChildProcess spawn: 'sleep' args: #('5') |
Csv class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
parse: | Primitive | string String - CSV string to parse | Array - array of rows, each a Dict keyed by the header row (a field missing from a short row is nil, a field beyond the last header is kept under its column number) | Csv parse: 'name,age\nAlice,30' |
parse:options: | Primitive | string String - CSV string to parse, options Dict - 'hasHeaders' -> false for Array rows (default true: Dict rows as parse:), 'delimiter' -> a one-byte String; any other key raises an Error | Array - parsed rows | Csv parse: 'name;age\nAlice;30' options: (Dict new at: 'delimiter' put: ';'; yourself) |
reader: | Primitive | string String - CSV string for streaming read | CsvReader - streaming CSV reader | Csv reader: (File read: 'data.csv') |
CsvReader
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
next | Primitive | - | Dict|nil - next row keyed by header (missing fields nil, extra fields under their column number), or nil at end | reader next |
atEnd | Primitive | - | Boolean - true if no more rows | reader atEnd |
DateTime class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
now | Primitive | - | Integer - current Unix timestamp in seconds | DateTime now |
parse: | Primitive | string String - ISO 8601 date string | Integer - Unix timestamp | DateTime parse: '2024-01-15T10:30:00Z' |
Dict
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
at: | Primitive | key String|Symbol - key to look up | Any - value for key; a missing key raises an Error (at:ifAbsent: for a key that may be missing; inside Maybe value: [...] it answers nil) | dict at: 'name' "=> 'Alice'" |
at:put: | Primitive | key String|Symbol - key to store, value Any - value to store | Any - the stored value | dict at: 'name' put: 'Bob' |
keys | Primitive | - | Array - array of all keys | dict keys "=> #('name' 'age')" |
size | Primitive | - | Integer - number of key-value pairs | dict size "=> 2" |
includesKey: | Primitive | key String|Symbol - key to check | Boolean - true if key exists | dict includesKey: 'name' "=> true" |
removeKey: | Primitive | key String|Symbol - key to remove | Any - removed value, or nil if key not found | dict removeKey: 'name' |
values | Primitive | - | Array - array of all values | dict values "=> #('Alice' 30)" |
keysAndValues | Primitive | - | Array - array of Association (key->value pairs) | dict keysAndValues do: [:assoc | assoc key display. assoc value displayNl] |
asString | Primitive | - | String - string representation | dict asString "=> 'Dict(name->Alice age->30)'" |
Dict class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
new | Primitive | - | Dict - new empty dictionary | Dict new |
Directory class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
entries: | Primitive | path String - directory path | Array - array of [name, isDir, size, mtime] tuples sorted by name (size is 0 for directories, mtime is Unix seconds; both 0 when the entry's metadata cannot be read). A directory that cannot be listed raises an Error with the reason | Directory entries: '.' |
Env class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
keys | Primitive | - | Array - array of all environment variable names | Env keys |
at: | Primitive | name String - environment variable name | String|nil - value or nil if not set; a value that is not valid Unicode raises an Error | Env at: 'PATH' |
at:put: | Primitive | name String - environment variable name (non-empty, no '=' or NUL; otherwise an Error), value String - value to set (no NUL; otherwise an Error) | String - the value | Env at: 'MY_VAR' put: 'value' |
File class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
read: | Primitive | path String - file path to read | String - file contents. A missing or unreadable file, or content that is not valid UTF-8, raises an Error with the path and the reason | File read: 'data.txt' |
read:encoding: | Primitive | path String - file path to read, encoding String - encoding name ('utf-8', 'shift-jis', 'euc-jp', etc.) | String - file contents decoded with specified encoding. An unreadable file, an unknown encoding or bytes invalid in that encoding raise an Error | File read: 'data.txt' encoding: 'shift-jis' |
write:content: | Primitive | path String - file path to write, content String - content to write | true on success; a file that cannot be written raises an Error with the path and the reason | File write: 'output.txt' content: 'Hello, World!' |
exists: | Primitive | path String - file path to check | Boolean - true if file exists, false otherwise (never raises) | File exists: 'data.txt' |
delete: | Primitive | path String - file path to delete | true on success; a missing or undeletable file raises an Error with the reason | File delete: 'temp.txt' |
glob: | Primitive | pattern String - glob pattern (e.g., '.txt', 'src/**/.rs') | Array - matching file paths, sorted (empty when nothing matches). An invalid pattern or an unreadable directory raises an Error | File glob: 'examples/*.st' |
appendTo:content: | Primitive | path String - file path to append to, content String - content to append | true on success (the file is created if absent); a failure raises an Error with the reason | File appendTo: 'log.txt' content: 'New log entry' |
mkdir: | Primitive | path String - directory path to create (with parents) | true on success, also when the directory already exists; a failure raises an Error with the reason | File mkdir: 'new_folder' |
copy:to: | Primitive | source String - source file path, dest String - destination file path | true on success; a failure raises an Error with the reason | File copy: 'original.txt' to: 'backup.txt' |
move:to: | Primitive | source String - source file path, dest String - destination file path | true on success (renames, or copies then deletes across drives); a failure raises an Error with the reason | File move: 'old.txt' to: 'new.txt' |
isDirectory: | Primitive | path String - path to check | Boolean - true if path is a directory, false otherwise (never raises) | File isDirectory: 'src' |
rmdir: | Primitive | path String - directory path to remove (must be empty) | true on success; a directory that is not empty or does not exist raises an Error with the reason | File rmdir: 'empty_folder' |
rmdir:recursive: | Primitive | path String - directory path to remove, recursive Boolean - true: remove the directory and all its contents; false: same as rmdir: (must be empty) | true on success; a failure raises an Error with the reason | File rmdir: 'folder' recursive: true |
size: | Primitive | path String - file path | Integer - file size in bytes; a missing or unreadable file raises an Error with the reason | File size: 'data.txt' |
readBinary: | Primitive | path String - file path to read | ByteArray - binary file contents; a missing or unreadable file raises an Error with the reason | File readBinary: 'image.png' |
writeBinary:content: | Primitive | path String - file path to write, content ByteArray - binary data to write | nil on success; a file that cannot be written raises an Error with the reason | File writeBinary: 'output.bin' content: (ByteArray new: 10) |
stdout | Primitive | - | WriteHandle - handle for stdout (buffered) | File stdout write: 'Output text' |
stderr | Primitive | - | WriteHandle - handle for stderr (buffered) | File stderr write: 'Error text' |
canonicalize: | Primitive | path String - file path to resolve | String|nil - absolute path with symlinks and . / .. resolved, nil if path does not exist; any other failure raises an Error | File canonicalize: 'src/../README.md' |
write:content:encoding: | Primitive | path String - file path to write, content String - content to write, encoding String - encoding name ('utf-8', 'shift-jis', 'euc-jp', etc.) | true on success; an unknown encoding, a character the encoding cannot represent, or a write failure raises an Error | File write: 'output.csv' content: data encoding: 'shift-jis' |
appendTo:content:encoding: | Primitive | path String - file path to append to, content String - content to append, encoding String - encoding name ('utf-8', 'shift-jis', 'euc-jp', etc.) | true on success; an unknown encoding, a character the encoding cannot represent, or a write failure raises an Error | File appendTo: 'log.txt' content: line encoding: 'euc-jp' |
Float
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
sin | Primitive | - | Float - sine value | 3.14159 sin "=> ~0.0" |
cos | Primitive | - | Float - cosine value | 0.0 cos "=> 1.0" |
tan | Primitive | - | Float - tangent value | 0.0 tan "=> 0.0" |
log | Primitive | - | Float - natural logarithm | 2.718 log "=> ~1.0" |
exp | Primitive | - | Float - e raised to this power | 1.0 exp "=> 2.718..." |
sqrt | Primitive | - | Float - square root | 16.0 sqrt "=> 4.0" |
log10 | Primitive | - | Float - base-10 logarithm | 100.0 log10 "=> 2.0" |
raisedTo: | Primitive | exponent Number - power to raise to | Float - result | 2.0 raisedTo: 10 "=> 1024.0" |
floor | Primitive | - | Integer - largest integer <= self | 3.7 floor "=> 3" |
ceiling | Primitive | - | Integer - smallest integer >= self | 3.2 ceiling "=> 4" |
rounded | Primitive | - | Integer - nearest integer | 3.5 rounded "=> 4" |
asString | Primitive | - | String - string representation | 3.14 asString "=> '3.14'" |
@ | Primitive | y Number - y coordinate | Point - new Point with self as x | 10.5 @ 20.5 "=> Point(10.5, 20.5)" |
Float class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
pi | Primitive | - | Float - mathematical constant pi | Float pi "=> 3.14159..." |
e | Primitive | - | Float - mathematical constant e | Float e "=> 2.71828..." |
infinity | Primitive | - | Float - positive infinity | Float infinity "=> Infinity" |
negativeInfinity | Primitive | - | Float - negative infinity | Float negativeInfinity "=> -Infinity" |
nan | Primitive | - | Float - Not a Number | Float nan "=> NaN" |
Grammar
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
setParserKind: | Primitive | parser_kind String - 'peg' or 'earley' | self | grammar setParserKind: 'peg' |
Grammar class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
from: | Primitive | source String - an EBNF grammar definition, one rule or terminal per line | Grammar - the compiled grammar, or nil if the definition is invalid (reason on stderr) | g := Grammar from: 'expr: /[0-9]+/ "+" /[0-9]+/' |
from:parser: | Primitive | source String - an EBNF grammar definition, one rule or terminal per line, parser String - 'peg' or 'earley'; a left-recursive grammar runs on Earley even when 'peg' is asked for | Grammar - the compiled grammar, or nil if the definition is invalid | g := Grammar from: 'expr: expr "+" /[0-9]+/ | /[0-9]+/' parser: 'earley' |
findAll:in: | Primitive | grammar Grammar - a compiled grammar, source String - the text to search | Array - each match responds to at: 'text' / 'start' / 'end' (1-based, inclusive char positions) and to every capture the grammar names, nil for one this match did not set | matches := Grammar findAll: g in: '1+2 and 3+4'. matches first at: 'text' |
Hmac class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
sha256:key: | Primitive | data String - data to authenticate, key String - secret key | String - HMAC-SHA256 as hex string | Hmac sha256: 'message' key: 'secret' |
Http class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
get: | Primitive | url String - URL to fetch | String - response body. Raises Error on a transport failure or an HTTP 4xx/5xx status (the message has the status and the body) | Http get: 'https://api.example.com/data' |
get:options: | Primitive | url String - URL to fetch, options Dict - options; the only option is 'headers' (a Dict of custom headers) | String - response body. Raises Error on a transport failure, an HTTP 4xx/5xx status, an unknown option or a header value that is not a String or Integer | Http get: 'https://api.example.com' options: (Dict new at: 'headers' put: headers) |
post:body: | Primitive | url String - URL to post to, body String - request body (typically JSON) | String - response body. Raises Error on a transport failure or an HTTP 4xx/5xx status | Http post: 'https://api.example.com' body: '{"name": "Alice"}' |
post:body:options: | Primitive | url String - URL to post to, body String - request body, options Dict - options with 'headers' key | String - response body. Raises Error on a transport failure, an HTTP 4xx/5xx status or a bad option/header | Http post: url body: json options: (Dict new at: 'headers' put: headers) |
put:body: | Primitive | url String - URL to put to, body String - request body | String - response body. Raises Error on a transport failure or an HTTP 4xx/5xx status | Http put: 'https://api.example.com/item/1' body: '{"name": "Bob"}' |
put:body:options: | Primitive | url String - URL to put to, body String - request body, options Dict - options with 'headers' key | String - response body. Raises Error on a transport failure, an HTTP 4xx/5xx status or a bad option/header | Http put: url body: json options: opts |
delete: | Primitive | url String - URL to delete | String - response body. Raises Error on a transport failure or an HTTP 4xx/5xx status | Http delete: 'https://api.example.com/item/1' |
delete:options: | Primitive | url String - URL to delete, options Dict - options with 'headers' key | String - response body. Raises Error on a transport failure, an HTTP 4xx/5xx status or a bad option/header | Http delete: url options: opts |
get:headers: | Primitive | url String - URL to fetch, headers Dict - custom headers (DEPRECATED: use get:options: instead) | String - response body. Raises Error on a transport failure, an HTTP 4xx/5xx status or a bad header | Http get: url headers: (Dict new at: 'Authorization' put: 'Bearer token') |
post:body:headers: | Primitive | url String - URL to post to, body String - request body, headers Dict - custom headers (DEPRECATED: use post:body:options: instead) | String - response body. Raises Error on a transport failure, an HTTP 4xx/5xx status or a bad header | Http post: url body: json headers: headers |
put:body:headers: | Primitive | url String - URL to put to, body String - request body, headers Dict - custom headers (DEPRECATED: use put:body:options: instead) | String - response body. Raises Error on a transport failure, an HTTP 4xx/5xx status or a bad header | Http put: url body: json headers: headers |
delete:headers: | Primitive | url String - URL to delete, headers Dict - custom headers (DEPRECATED: use delete:options: instead) | String - response body. Raises Error on a transport failure, an HTTP 4xx/5xx status or a bad header | Http delete: url headers: headers |
getWithHeaders: | Primitive | url String - URL to fetch | Dict - 'status' (Integer), 'headers' (Dict, lowercase names) and 'body' (String), for any HTTP status. Raises Error on a transport failure or an unreadable body | (Http getWithHeaders: url) at: 'status' |
Integer
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
sin | Primitive | - | Float - sine value | 0 sin "=> 0.0" |
cos | Primitive | - | Float - cosine value | 0 cos "=> 1.0" |
tan | Primitive | - | Float - tangent value | 0 tan "=> 0.0" |
log | Primitive | - | Float - natural logarithm | 10 log "=> 2.302..." |
exp | Primitive | - | Float - e raised to this power | 1 exp "=> 2.718..." |
sqrt | Primitive | - | Float - square root | 16 sqrt "=> 4.0" |
log10 | Primitive | - | Float - base-10 logarithm | 100 log10 "=> 2.0" |
raisedTo: | Primitive | exponent Number - power to raise to | Number - exact (Integer, or Fraction for a negative exponent) when the exponent is an Integer; Float otherwise | 2 raisedTo: 100 "=> 1267650600228229401496703205376" |
floor | Primitive | - | Integer - self (integers are already whole) | 42 floor "=> 42" |
ceiling | Primitive | - | Integer - self (integers are already whole) | 42 ceiling "=> 42" |
rounded | Primitive | - | Integer - self (integers are already whole) | 42 rounded "=> 42" |
bitShift: | Primitive | count Integer - number of bits to shift (positive=left, negative=right) | Integer - shifted value | 1 bitShift: 10 "=> 1024" |
bitAnd: | Primitive | other Integer - value to AND with | Integer - bitwise AND result | 7 bitAnd: 3 "=> 3" |
bitOr: | Primitive | other Integer - value to OR with | Integer - bitwise OR result | 4 bitOr: 3 "=> 7" |
bitXor: | Primitive | other Integer - value to XOR with | Integer - bitwise XOR result | 7 bitXor: 3 "=> 4" |
asString | Primitive | - | String - decimal string representation | 42 asString "=> '42'" |
asCharacter | Primitive | - | Character - Unicode character for this code point | 65 asCharacter "=> $A" |
format: | Primitive | pattern String - strftime format pattern | String - the receiver (Unix seconds) as local time; an invalid pattern or an out-of-range timestamp raises an Error | DateTime now format: '%Y-%m-%d' "=> '2026-01-17'" |
formatUtc: | Primitive | pattern String - strftime format pattern | String - the receiver (Unix seconds) as UTC time; an invalid pattern or an out-of-range timestamp raises an Error | DateTime now formatUtc: '%Y-%m-%d' "=> '2026-01-17'" |
@ | Primitive | y Number - y coordinate | Point - new Point with self as x | 10 @ 20 "=> Point(10, 20)" |
Interval
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
start | Primitive | - | Integer - start value | (1 to: 10) start "=> 1" |
stop | Primitive | - | Integer - end value | (1 to: 10) stop "=> 10" |
step | Primitive | - | Integer - step value | (1 to: 10 by: 2) step "=> 2" |
size | Primitive | - | Integer - number of elements | (1 to: 10) size "=> 10" |
asArray | Primitive | - | Array - interval as array | (1 to: 5) asArray "=> #(1 2 3 4 5)" |
includes: | Primitive | value Integer - value to check | Boolean - true if in interval | (1 to: 10) includes: 5 "=> true" |
by: | Primitive | step Integer - new step value | Interval - new interval with step | (1 to: 10) by: 2 |
Interval class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
from:to: | Primitive | start Integer - start value, end Integer - end value | Interval - new interval with step 1 | Interval from: 1 to: 10 |
from:to:by: | Primitive | start Integer - start value, end Integer - end value, step Integer - step value | Interval - new interval with custom step | Interval from: 1 to: 10 by: 2 |
Json class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
parse: | Primitive | string String - JSON string to parse | Any - parsed value (Dict, Array, String, Integer, Float, Boolean, nil) | Json parse: '{"name": "Alice", "age": 30}' |
generate: | Primitive | value Any - value to serialize | String - JSON string (Symbols and Characters as strings, OrderedCollections as arrays); a value JSON cannot represent (an instance, a block, NaN or Infinity, an integer beyond 64 bits, an object Dictionary key) raises an Error | Json generate: (Dict new at: 'name' put: 'Alice') |
generate:options: | Primitive | value Any - value to serialize, options Dict - options (e.g., 'pretty' -> true) | String - JSON string; errors as for generate: | Json generate: data options: (Dict new at: 'pretty' put: true) |
Object
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
name | Primitive | - | String - the class's short name, as written in its definition. Not unique: two modules may each define a class of the same name, so use fullName to tell them apart. | Object subclass: #Point2D instanceVariableNames: ''. Point2D name "=> 'Point2D'" |
fullName | Primitive | - | String - the module-qualified class name ('Http.Router.WebApp'), or the plain name for a builtin or a Core class. This is what identifies a class. | Module import: 'Testing'. TestRunner fullName "=> 'Testing.TestRunner'" |
isKindOf: | Primitive | aClass Class - the class to test against | Boolean - true when the receiver is an instance of aClass or of one of its subclasses | 3 isKindOf: Integer "=> true" |
respondsTo: | Primitive | aSelector Symbol - the selector to look for | Boolean - true when the receiver's class, or a superclass, implements the selector | 'abc' respondsTo: #size "=> true" |
hash | Primitive | - | Integer - a hash of the receiver, consistent with = | 'abc' hash = 'abc' hash "=> true" |
OrderedCollection
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
size | Primitive | - | Integer - number of elements | coll size |
add: | Primitive | value Any - value to append | self | coll add: 42 |
addFirst: | Primitive | value Any - value to prepend | self | coll addFirst: 1 |
removeFirst | Primitive | - | Any - removed first element | coll removeFirst |
removeLast | Primitive | - | Any - removed last element | coll removeLast |
remove: | Primitive | value Any - value to remove | Any - removed value, or nil if not found | coll remove: 42 |
at: | Primitive | index Integer - 1-based index | Any - element at index; an index outside the collection raises an Error | coll at: 1 |
at:put: | Primitive | index Integer - 1-based index of an existing element, value Any - the new element | Any - the value; an index outside the collection raises an Error (use add: to grow it) | coll at: 1 put: 'x' |
includes: | Primitive | value Any - value to search for | Boolean - true if found | coll includes: 42 |
first | Primitive | - | Any - first element | coll first |
last | Primitive | - | Any - last element | coll last |
asArray | Primitive | - | Array - elements as array | coll asArray |
copyFrom:to: | Primitive | start Integer - 1-based start index, end Integer - 1-based end index (inclusive) | OrderedCollection - new sliced collection | coll copyFrom: 2 to: 4 |
OrderedCollection class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
new | Primitive | - | OrderedCollection - new empty collection | OrderedCollection new |
ParseTree
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
captureNamed: | Primitive | name String - capture name | String - captured text, or nil if not found | tree captureNamed: 'className' |
capturesNamed: | Primitive | name String - capture name | Array - array of all captured texts with that name | tree capturesNamed: 'param' |
captureNodeNamed: | Primitive | name String - capture name | ParseTree - the capture node itself, or nil if not found | tree captureNodeNamed: 'body' |
children | Primitive | - | Array - array of child ParseTree nodes | tree children |
text | Primitive | - | String - the text content of this node | tree text |
name | Primitive | - | String - the name of this node (rule name, terminal name, or capture name) | tree name |
isTerminal | Primitive | - | Boolean - true if this is a terminal node | tree isTerminal |
isNonTerminal | Primitive | - | Boolean - true if this is a non-terminal node | tree isNonTerminal |
isCapture | Primitive | - | Boolean - true if this is a capture node | tree isCapture |
Path class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
basename: | Primitive | path String - file path | String - file name without directory | Path basename: '/home/user/file.txt' "=> 'file.txt'" |
dirname: | Primitive | path String - file path | String - directory part of path | Path dirname: '/home/user/file.txt' "=> '/home/user'" |
extension: | Primitive | path String - file path | String - file extension (without dot) | Path extension: 'file.txt' "=> 'txt'" |
join:with: | Primitive | base String - base path, child String - child path | String - joined path | Path join: '/home' with: 'user' "=> '/home/user'" |
absolute: | Primitive | path String - relative path | String|nil - the absolute path with links resolved (on Windows C:... or \server\share..., without the \?\ prefix), or nil if the path does not exist; any other failure (no permission, invalid path) raises an Error with the OS reason | Path absolute: 'file.txt' |
exists: | Primitive | path String - path to check | Boolean - true if path exists | Path exists: '/tmp' |
isDirectory: | Primitive | path String - path to check | Boolean - true if path is a directory | Path isDirectory: '/tmp' |
Point
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
x | Primitive | - | Number - x coordinate | (10 @ 20) x "=> 10" |
y | Primitive | - | Number - y coordinate | (10 @ 20) y "=> 20" |
x: | Primitive | value Number - new x coordinate | self | point x: 30 |
y: | Primitive | value Number - new y coordinate | self | point y: 40 |
Process class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
run:args: | Primitive | command String - command to run (not through a shell), args Array - the arguments: Strings, or Integers (passed as their decimal digits); any other element raises an Error naming its position | Integer - the exit code; 128 + the signal number for a process a signal ended (Unix). A command that cannot be started (not found, no permission) raises an Error naming it and the OS reason | Process run: 'ls' args: #('-la') |
output:args: | Primitive | command String - command to run (not through a shell), args Array - the arguments, as for run:args: | String - the captured stdout, whatever the exit code (use run:args: when the code matters); stderr passes through to this process's stderr. A command that cannot be started raises an Error naming it and the OS reason | Process output: 'echo' args: #('hello') |
Random class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
next | Primitive | - | Float - random float between 0.0 and 1.0 | Random next |
nextInt: | Primitive | max Integer - exclusive upper bound | Integer - random integer from 0 to max-1 (uniform); a max of 0 or less raises an Error | Random nextInt: 100 |
Set
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
add: | Primitive | value Any - value to add | self | set add: 42 |
includes: | Primitive | value Any - value to check | Boolean - true if member | set includes: 42 |
size | Primitive | - | Integer - number of elements | set size |
remove: | Primitive | value Any - value to remove | Any - removed value, or nil | set remove: 42 |
union: | Primitive | other Set - set to union with | Set - new set with all elements | set1 union: set2 |
intersection: | Primitive | other Set - set to intersect with | Set - new set with common elements | set1 intersection: set2 |
difference: | Primitive | other Set - set to subtract | Set - new set with elements not in other | set1 difference: set2 |
asArray | Primitive | - | Array - elements as array | set asArray |
Set class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
new | Primitive | - | Set - new empty set | Set new |
Sha2 class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
hash256: | Primitive | data String - data to hash | String - SHA-256 hash as hex string | Sha2 hash256: 'hello' |
sha256: | Primitive | data String - data to hash (alias for hash256:) | String - SHA-256 hash as hex string | Sha2 sha256: 'hello' |
hash512: | Primitive | data String - data to hash | String - SHA-512 hash as hex string | Sha2 hash512: 'hello' |
sha512: | Primitive | data String - data to hash (alias for hash512:) | String - SHA-512 hash as hex string | Sha2 sha512: 'hello' |
Sqlite
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
execute: | Primitive | sql String - one or more SQL statements separated by ';', all executed in order | Integer - number of rows inserted, updated or deleted; raises Error with SQLite's message on failure | db execute: 'CREATE TABLE users (id INTEGER, name TEXT)' |
execute:with: | Primitive | sql String - one SQL statement with ? placeholders, params Array - parameter values (Integer, Float, String, ByteArray, Boolean as 1/0, nil as NULL) | Integer - number of rows inserted, updated or deleted; raises Error with SQLite's message on failure | db execute: 'INSERT INTO users VALUES (?, ?)' with: #(1 'Alice') |
query: | Primitive | sql String - one SELECT statement | Array - array of Dict rows (empty when no row matches); raises Error with SQLite's message on failure | db query: 'SELECT * FROM users' |
query:with: | Primitive | sql String - one SELECT statement with ? placeholders, params Array - parameter values (as for execute:with:) | Array - array of Dict rows (empty when no row matches); raises Error with SQLite's message on failure | db query: 'SELECT * FROM users WHERE id = ?' with: #(1) |
queryScalar: | Primitive | sql String - one SELECT statement | Any - first column of the first row (nil when no row matches); raises Error with SQLite's message on failure | db queryScalar: 'SELECT COUNT(*) FROM users' |
queryScalar:with: | Primitive | sql String - one SELECT statement with ? placeholders, params Array - parameter values (as for execute:with:) | Any - first column of the first row (nil when no row matches); raises Error with SQLite's message on failure | db queryScalar: 'SELECT name FROM users WHERE id = ?' with: #(1) |
Sqlite class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
open: | Primitive | path String - database file path (':memory:' for in-memory DB) | Sqlite - database connection; raises Error with SQLite's reason if it cannot be opened | Sqlite open: 'mydb.sqlite' |
openWith: | Primitive | path String - database file path (alias for open:) | Sqlite - database connection; raises Error with SQLite's reason if it cannot be opened | Sqlite openWith: ':memory:' |
Stdin class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
readLine | Primitive | - | String|nil - one line from standard input without its line ending ('' for an empty line), nil at end of input; a read error (e.g. invalid UTF-8) raises an Error | Stdin readLine |
readAll | Primitive | - | String - all remaining input from stdin ('' when there is none); a read error (e.g. invalid UTF-8) raises an Error | Stdin readAll |
String
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
size | Primitive | - | Integer - number of characters | 'hello' size "=> 5" |
at: | Primitive | index Integer - 1-based index | Character - character at index; an index outside the string raises an Error | 'hello' at: 2 "=> $e" |
, | Primitive | other String - string to append | String - concatenated string | 'hello' , ' world' "=> 'hello world'" |
split: | Primitive | delimiter String - delimiter to split on | Array - array of substrings | 'a,b,c' split: ',' "=> #('a' 'b' 'c')" |
trim | Primitive | - | String - string with leading/trailing whitespace removed | ' hello ' trim "=> 'hello'" |
asUppercase | Primitive | - | String - uppercase version | 'hello' asUppercase "=> 'HELLO'" |
asLowercase | Primitive | - | String - lowercase version | 'HELLO' asLowercase "=> 'hello'" |
includes: | Primitive | substring String - substring to search for | Boolean - true if contains substring | 'hello' includes: 'ell' "=> true" |
beginsWith: | Primitive | prefix String - prefix to check | Boolean - true if starts with prefix | 'hello' beginsWith: 'he' "=> true" |
endsWith: | Primitive | suffix String - suffix to check | Boolean - true if ends with suffix | 'hello' endsWith: 'lo' "=> true" |
copyFrom:to: | Primitive | start Integer - 1-based start index, end Integer - 1-based end index (inclusive) | String - substring | 'hello' copyFrom: 2 to: 4 "=> 'ell'" |
replace:with: | Primitive | old String - substring to replace (first occurrence), new String - replacement string | String - new string with replacement | 'hello' replace: 'l' with: 'L' "=> 'heLlo'" |
replaceAll:with: | Primitive | old String - substring to replace (all occurrences), new String - replacement string | String - new string with all replacements | 'hello' replaceAll: 'l' with: 'L' "=> 'heLLo'" |
* | Primitive | count Integer - number of repetitions | String - repeated string | 'ab' * 3 "=> 'ababab'" |
match: | Primitive | pattern String - regex pattern | Boolean - true if matches; an invalid regex raises an Error with the regex parser's message | 'hello' match: 'h.*o' "=> true" |
matchGroups: | Primitive | pattern String - regex pattern with capture groups | Dict|nil - the whole match under 'match', each group under its number from '1' (and a named group (?P | ('hello123' matchGroups: '([a-z]+)([0-9]+)') at: '2' "=> '123'" |
regexMatches: | Primitive | pattern String - regex pattern | Array - every match in order as #(start stop groups): 1-based character positions (stop inclusive) and a Dict keyed as matchGroups: keys it ('match', '1', '2', ..., names); an invalid regex raises an Error | ('a1b22' regexMatches: '[0-9]+') collect: [:m | m first] "=> #(2 4)" |
extract: | Primitive | pattern String - template, not a regex: literal text with %name placeholders | Dict|nil - each placeholder's text keyed by its name, or nil if the template does not match; a placeholder name used twice raises an Error | ('user=alice id=42' extract: 'user=%name id=%id') at: 'id' "=> '42'" |
replaceRegex:with: | Primitive | pattern String - regex pattern, replacement String - replacement: $match is the whole match, $1, $2, ... (or $name) a group, ${...} when letters follow, $$ a dollar sign; $0 raises an Error (the whole match is $match) | String - string with all matches replaced; an invalid regex raises an Error with the regex parser's message | 'hello world' replaceRegex: '\\w+' with: '[$match]' "=> '[hello] [world]'" |
asInteger | Primitive | - | Integer|nil - parsed integer value, nil if the text is not an integer | '42' asInteger "=> 42" |
asNumber | Primitive | - | Number|nil - parsed Integer or Float, nil if the text is not a number | '3.14' asNumber "=> 3.14" |
asString | Primitive | - | String - self | 'hello' asString "=> 'hello'" |
displayWidth | Primitive | - | Integer - display width (handles CJK characters) | 'hello' displayWidth "=> 5" |
findString:startingAt: | Primitive | substring String - substring to find, start Integer - 1-based character position to start from | Integer - 1-based character index, or 0 if not found | 'hello' findString: 'l' startingAt: 1 "=> 3" |
indexOf: | Primitive | substring String - substring to find | Integer - 1-based index, or 0 if not found | 'hello' indexOf: 'l' "=> 3" |
regexEscape | Primitive | - | String - string with regex metacharacters escaped | 'a.b*c' regexEscape "=> 'a\\.b\\*c'" |
asSymbol | Primitive | - | Symbol - the symbol with the receiver's characters (ANSI 5.7.10.8); a Symbol answers itself | 'at:put:' asSymbol "=> #at:put:" |
copyReplaceAll:with: | Primitive | old String - substring to replace, new String - replacement | String - every non-overlapping occurrence, left to right, replaced (ANSI 5.7.10.10; same as replaceAll:with:) | 'abcabc' copyReplaceAll: 'bc' with: 'X' "=> 'aXaX'" |
StringStream
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
nextPutAll: | Primitive | string String - string to append | self | stream nextPutAll: 'Hello' |
contents | Primitive | - | String - accumulated string contents | stream contents |
size | Primitive | - | Integer - current length of contents | stream size |
reset | Primitive | - | self - clears the buffer | stream reset |
nextPut: | Primitive | char Character - character to append | self | stream nextPut: $A |
StringStream class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
new | Primitive | - | StringStream - new empty string stream | StringStream new |
new: | Primitive | initialCapacity Integer - initial buffer capacity | StringStream - new string stream with capacity | StringStream new: 1024 |
System
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
cwd | Primitive | - | String - the current working directory; raises an Error with the OS reason if it cannot be read (e.g. it was deleted) | System cwd |
chdir: | Primitive | path String - the directory to change to | Boolean - true; raises an Error naming the path and the OS reason when the directory cannot be entered | System chdir: '/tmp' |
System class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
args | Primitive | - | Array - command line arguments | System args |
heapSize | Primitive | - | Integer - current heap size in bytes | System heapSize |
stringHeapSize | Primitive | - | Integer - current string heap size (number of string objects) | System stringHeapSize |
platform | Primitive | - | String - platform name ('windows', 'linux', 'macos') | System platform |
exit: | Primitive | code Integer - exit code | never returns (process exits) | System exit: 0 |
nilTolerantEnter | Primitive | - | nil - enters nil-tolerant mode (nil message sends return nil) | System nilTolerantEnter |
nilTolerantLeave | Primitive | - | nil - leaves nil-tolerant mode | System nilTolerantLeave |
isNilTolerant | Primitive | - | Boolean - true if in nil-tolerant mode | System isNilTolerant |
performGC | Primitive | - | nil - triggers garbage collection | System performGC |
gc | Primitive | - | nil - alias for performGC | System gc |
gcThreshold | Primitive | - | Integer - current GC threshold in bytes | System gcThreshold |
gcThreshold: | Primitive | bytes Integer - new GC threshold in bytes | nil | System gcThreshold: 1000000 |
onInterrupt: | Primitive | block Block - handler to call on SIGINT (Ctrl+C); a later onInterrupt: replaces it | nil - raises an Error with the OS reason if the signal handler cannot be installed | System onInterrupt: [ 'Interrupted!' displayNl. System exit: 1 ] |
clearInterruptHandler | Primitive | - | nil - removes the interrupt handler | System clearInterruptHandler |
classNamed: | Primitive | name String - a module-qualified class name ('Testing.TestRunner'), or a short name when only one class carries it | Class|nil - the class object, or nil when no class matches or when a short name is ambiguous (two modules may each define a class of that name; qualify it) | System classNamed: 'String' |
allClasses | Primitive | - | Array - the module-qualified name of every class in the system; a builtin or Core class appears under its plain name | System allClasses |
sleep: | Primitive | ms Integer - milliseconds to sleep | nil | System sleep: 1000 |
cwd | Primitive | - | String - the current working directory; raises an Error with the OS reason if it cannot be read (e.g. it was deleted) | System cwd |
chdir: | Primitive | path String - the directory to change to | Boolean - true; raises an Error naming the path and the OS reason when the directory cannot be entered | System chdir: '/tmp' |
Tcp class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
connect:port: | Primitive | host String - hostname or IP address, port Integer - port number (0..65535) | TcpStream - connection. Raises Error naming host:port and the reason when the connection cannot be made | Tcp connect: 'localhost' port: 8080 |
connect:port:timeout: | Primitive | host String - hostname or IP address, port Integer - port number (0..65535), timeout Integer - timeout in milliseconds (positive) | TcpStream - connection. Raises Error naming host:port and the reason (including a timeout) | Tcp connect: 'localhost' port: 8080 timeout: 5000 |
TcpListener
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
accept | Primitive | - | TcpStream - accepted connection (blocking). Raises Error with the reason when accept fails or the listener is closed | listener accept |
close | Primitive | - | Boolean - true. Releases the port; closing twice is not an error | listener close |
TcpListener class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
listen: | Primitive | port Integer - port to listen on (binds to 0.0.0.0) | TcpListener - listener. Raises Error with the reason when the port cannot be bound | TcpListener listen: 8080 |
listenOn:port: | Primitive | address String - address to bind (e.g., '127.0.0.1'), port Integer - port to listen on | TcpListener - listener. Raises Error with the reason when the address cannot be bound | TcpListener listenOn: '127.0.0.1' port: 8080 |
TcpStream
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
send: | Primitive | data String|ByteArray - data to send | Integer - bytes sent (all of data). Raises Error when the write fails | stream send: 'GET / HTTP/1.0\r\n\r\n' |
recv: | Primitive | maxBytes Integer - maximum bytes to receive (0 or more) | ByteArray - received data, or nil when the peer has closed. Raises Error on a read error or a read timeout (30 s) | stream recv: 4096 |
recv | Primitive | - | ByteArray - received data (at most 4096 bytes), or nil when the peer has closed. Raises Error on a read error or timeout | stream recv |
recvLine | Primitive | - | String - line without newline, or nil when the peer has closed. Raises Error on a read error, a timeout or a line that is not UTF-8 | stream recvLine |
close | Primitive | - | Boolean - true. Shuts down both directions; closing an already closed connection is not an error | stream close |
Template class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
render:with: | Primitive | template String - Mustache template string, data Dict - data dictionary for template rendering | String - rendered result; a template that does not compile or render raises an Error with mustache's message | Template render: 'Hello, {{name}}!' with: (Dict new at: 'name' put: 'World') |
Time class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
millisecondClock | Primitive | - | Integer - milliseconds since VM startup (monotonic) | Time millisecondClock |
nanosecondClock | Primitive | - | Integer - nanoseconds since VM startup (monotonic) | Time nanosecondClock |
Toml class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
parse: | Primitive | string String - TOML string to parse | Dict - parsed TOML as dictionary | Toml parse: '[section]\nkey = "value"' |
WriteHandle
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
write: | Primitive | content String - string to write (no newline) | self; a write failure raises an Error with the reason | handle write: 'Hello' |
writeLine: | Primitive | content String - string to write with newline | self; a write failure raises an Error with the reason | handle writeLine: 'Hello World' |
flush | Primitive | - | self - flushes buffer to disk; a failure raises an Error with the reason | handle flush |
close | Primitive | - | nil - flushes and closes the file; a failed flush raises an Error with the reason | handle close |
WriteHandle class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
open: | Primitive | path String - file path to write | WriteHandle - handle for streaming writes (creates or truncates the file); a file that cannot be created raises an Error with the reason | handle := WriteHandle open: 'output.txt' |
Yaml class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
parse: | Primitive | string String - YAML string to parse | Any - parsed value | Yaml parse: 'name: Alice\nage: 30' |
標準ライブラリ
Classes defined in lib/*.st.
Ansi class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
esc | Smalltalk | - | String - ESC character | Ansi esc |
csi | Smalltalk | - | String - CSI sequence (ESC[) | Ansi csi |
reset | Smalltalk | - | String - ANSI reset sequence | Ansi reset |
wrap: aString with: code | Smalltalk | aString String - text to wrap, code String - ANSI code | String - wrapped with ANSI escape | Ansi wrap: 'hello' with: '31' |
Array
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
product | Smalltalk | - | Number - product of all elements | #(1 2 3 4) product => 24 |
first | Smalltalk | - | Object - first element | #(a b c) first |
last | Smalltalk | - | Object - last element | #(a b c) last |
allButFirst | Smalltalk | - | Array - all elements except first | #(1 2 3) allButFirst |
allButLast | Smalltalk | - | Array - all elements except last | #(1 2 3) allButLast |
take: count | Smalltalk | count Integer - number of elements to take | Array - first count elements | #(1 2 3 4 5) take: 3 |
drop: count | Smalltalk | count Integer - number of elements to skip | Array - remaining elements after skip | #(1 2 3 4 5) drop: 2 |
copy | Smalltalk | - | Array - shallow copy | #(1 2 3) copy |
copyWith: element | Smalltalk | element Object - element to append | Array - new array with element at end | #(1 2) copyWith: 3 |
copyWithout: element | Smalltalk | element Object - element to remove | Array - new array without element | #(1 2 3 2) copyWithout: 2 |
= anObject | Smalltalk | anObject Object - the object to compare with | Boolean - true for an Array of the same size whose elements are = in order | #(1 2) = #(1 2) |
indexOf: element | Smalltalk | element Object - element to find | Integer - 1-based index or 0 if not found | #(a b c) indexOf: b |
flatten | Smalltalk | - | Array - flattened by one level | #((1 2) (3 4)) flatten |
unique | Smalltalk | - | Array - with duplicates removed | #(1 2 1 3 2) unique |
reversed | Smalltalk | - | Array - elements in reverse order | #(1 2 3) reversed |
zip: other | Smalltalk | other Array - array to zip with | Array - array of pairs | #(1 2 3) zip: #(a b c) |
sortBy: aBlock | Smalltalk | aBlock Block - comparator [:a :b | a < b] returns true if a should come before b | Array - sorted by comparator | #(3 1 4) sortBy: [:a :b | a > b] |
Array class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
withAll: aCollection | Smalltalk | aCollection Collection - source collection | Array - new array with all elements | Array withAll: (1 to: 5) |
with: anObject | Smalltalk | anObject Object - the element | Array - single-element array | Array with: 42 |
with: first with: second | Smalltalk | first Object - first element, second Object - second element | Array - two-element array | Array with: 1 with: 2 |
with: first with: second with: third | Smalltalk | first Object - first element, second Object - second element, third Object - third element | Array - three-element array | Array with: 1 with: 2 with: 3 |
with: first with: second with: third with: fourth | Smalltalk | first Object - first element, second Object - second element, third Object - third element, fourth Object - fourth element | Array - four-element array | Array with: 1 with: 2 with: 3 with: 4 |
ByteArray
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
do: aBlock | Smalltalk | aBlock Block - block to evaluate for each element (byte value 0-255) | nil | (ByteArray fromString: 'ABC') do: [:b | b displayNl] |
CLI.ArgParser
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
name: aName | Smalltalk | aName String - program name | ArgParser - self for chaining | parser name: 'my-tool' |
description: desc | Smalltalk | desc String - program description | ArgParser - self for chaining | parser description: 'A useful tool' |
flag: longName short: shortName description: desc | Smalltalk | longName String - long flag name, shortName String - short flag name, desc String - description | ArgParser - self for chaining | parser flag: 'verbose' short: 'v' description: 'Verbose' |
option: longName short: shortName description: desc | Smalltalk | longName String - long option name, shortName String - short option name, desc String - description | ArgParser - self for chaining | parser option: 'output' short: 'o' description: 'Output file' |
positional: aName description: desc | Smalltalk | aName String - positional arg name, desc String - description | ArgParser - self for chaining | parser positional: 'input' description: 'Input file' |
parse: args | Smalltalk | args Array - command line arguments | ParseResult - parsed result | parser parse: System args |
CLI.ParseResult
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
isSuccess | Smalltalk | - | Boolean - true if parse succeeded | result isSuccess |
flag: name | Smalltalk | name String - flag name | Boolean - true if flag was set | result flag: 'verbose' |
option: name | Smalltalk | name String - option name | String - option value or nil | result option: 'output' |
positional: name | Smalltalk | name String - positional arg name | String - positional value or nil | result positional: 'input' |
extras | Smalltalk | - | Array - extra positional arguments | result extras |
Collection
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
isEmpty | Smalltalk | - | Boolean - true if collection has no elements | #() isEmpty |
notEmpty | Smalltalk | - | Boolean - true if collection has at least one element | #(1 2 3) notEmpty |
second | Smalltalk | - | Object - the second element | #(a b c) second |
third | Smalltalk | - | Object - the third element | #(a b c) third |
do: aBlock | Smalltalk | aBlock Block - block to evaluate for each element | nil | #(1 2 3) do: [:x | x displayNl] |
collect: aBlock | Smalltalk | aBlock Block - transformation block | Collection - new collection with transformed elements | #(1 2 3) collect: [:x | x * 2] |
select: aBlock | Smalltalk | aBlock Block - predicate block | Collection - elements where block returns true | #(1 2 3 4) select: [:x | x > 2] |
reject: aBlock | Smalltalk | aBlock Block - predicate block | Collection - elements where block returns false | #(1 2 3 4) reject: [:x | x > 2] |
detect: aBlock | Smalltalk | aBlock Block - predicate block | Object - first matching element or nil | #(1 2 3 4) detect: [:x | x > 2] |
detect: aBlock ifNone: exceptionBlock | Smalltalk | aBlock Block - predicate block, exceptionBlock Block - block to evaluate if not found | Object - first match or exceptionBlock result | #(1 2 3) detect: [:x | x > 5] ifNone: [0] |
inject: initialValue into: aBlock | Smalltalk | initialValue Object - initial accumulator value, aBlock Block - two-arg block [:acc :each | ...] | Object - final accumulated value | #(1 2 3) inject: 0 into: [:sum :x | sum + x] |
doWithIndex: aBlock | Smalltalk | aBlock Block - two-arg block [:elem :index | ...] | nil | #(a b c) doWithIndex: [:e :i | (i,e) displayNl] |
ifEmpty: aBlock | Smalltalk | aBlock Block - block to evaluate if empty | Object - block result or self | #() ifEmpty: ['none'] |
ifNotEmpty: aBlock | Smalltalk | aBlock Block - block to evaluate with self | Object - block result or self | #(1 2) ifNotEmpty: [:c | c size] |
count: aBlock | Smalltalk | aBlock Block - predicate block | Integer - count of matches | #(1 2 3 4) count: [:x | x > 2] |
includes: anObject | Smalltalk | anObject Object - object to find | Boolean - true if found | #(1 2 3) includes: 2 |
join: separator | Smalltalk | separator String - separator between elements | String - joined elements | #(1 2 3) join: ', ' |
anySatisfy: aBlock | Smalltalk | aBlock Block - predicate block | Boolean - true if any match | #(1 2 3) anySatisfy: [:x | x > 2] |
allSatisfy: aBlock | Smalltalk | aBlock Block - predicate block | Boolean - true if all match | #(2 4 6) allSatisfy: [:x | x even] |
noneSatisfy: aBlock | Smalltalk | aBlock Block - predicate block | Boolean - true if none match | #(1 3 5) noneSatisfy: [:x | x even] |
groupBy: keyBlock | Smalltalk | keyBlock Block - block to compute key | Dictionary - grouped elements | #(1 2 3 4) groupBy: [:x | x even] |
tally | Smalltalk | - | Dictionary - element occurrence counts | #(a b a c) tally |
reverseDo: aBlock | Smalltalk | aBlock Block - one-arg block, called with each element, last first (ANSI 5.7.8.27) | - | #(1 2 3) reverseDo: [:x | x displayNl] |
reverse | Smalltalk | - | Collection - the elements in reverse order, same kind as the receiver (ANSI 5.7.8.26) | 'abc' reverse => 'cba' |
with: aCollection do: aBlock | Smalltalk | aCollection Collection - same size as the receiver, aBlock Block - two-arg block, called with the elements at each index (ANSI 5.7.8.28) | - | #(1 2) with: #(10 20) do: [:a :b | (a + b) displayNl] |
from: start to: stop do: aBlock | Smalltalk | start Integer - first index, stop Integer - last index, aBlock Block - one-arg block, called with each element in that range (ANSI 5.7.8.18) | - | #(10 20 30) from: 2 to: 3 do: [:x | x displayNl] |
keysAndValuesDo: aBlock | Smalltalk | aBlock Block - two-arg block, called with each index and element (ANSI 5.7.8.24) | - | 'ab' keysAndValuesDo: [:i :c | i displayNl] |
copyWith: newElement | Smalltalk | newElement Object - appended element | Collection - a copy of the receiver with newElement at the end (ANSI 5.7.8.12) | 'abc' copyWith: $d => 'abcd' |
copyReplaceAll: targetElements with: replacementElements | Smalltalk | targetElements Collection - subsequence to find, replacementElements Collection - what replaces each match | Collection - a copy with every non-overlapping match, left to right, replaced (ANSI 5.7.8.8) | #(1 2 3 1 2) copyReplaceAll: #(1 2) with: #(9) => #(9 3 9) |
do: aBlock separatedBy: separatorBlock | Smalltalk | aBlock Block - one-arg block for each element, separatorBlock Block - evaluated between elements, not before the first (ANSI 5.7.1.14) | - | #(1 2 3) do: [:x | x display] separatedBy: [', ' display] |
asArray | Smalltalk | - | Array - the receiver's elements, in order if it has one (ANSI 5.7.1.3) | - |
asOrderedCollection | Smalltalk | - | OrderedCollection - the receiver's elements, in order if it has one (ANSI 5.7.1.6) | - |
asSet | Smalltalk | - | Set - the receiver's elements without duplicates (ANSI 5.7.1.7) | - |
addAll: aCollection | Smalltalk | aCollection Collection - elements to add with add:, in its do: order (ANSI 5.7.5.2) | Collection - aCollection | - |
remove: oldElement | Smalltalk | oldElement Object - the first element = to it is removed | Collection - self | coll remove: 3 |
remove: oldElement ifAbsent: aBlock | Smalltalk | oldElement Object - element to remove (the first equal one), aBlock Block - evaluated, and its value answered, when there is none (ANSI 5.7.5.4) | Object - the removed element | - |
removeAll: aCollection | Smalltalk | aCollection Collection - each element is removed with remove: (ANSI 5.7.5.5) | Collection - aCollection | - |
Collection class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
withAll: aCollection | Smalltalk | aCollection Collection - source collection | Collection - new collection with all elements | OrderedCollection withAll: #(1 2 3) |
Core.Association class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
key: aKey value: aValue | Smalltalk | aKey Object - the key, aValue Object - the value | Association - key-value pair | Association key: 'name' value: 'John' |
Core.Block
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
valueWithArguments: anArray | Smalltalk | anArray Array - the arguments, as many as the block takes (ANSI 5.4.1.2) | Object - the block's value | [:a :b | a + b] valueWithArguments: #(1 2) => 3 |
ifCurtailed: terminationBlock | Smalltalk | terminationBlock Block - evaluated only if the receiver does not complete normally (non-local return, exception unwinding) (ANSI 5.4.3.2) | Object - the receiver's value | - |
timeToRun | Smalltalk | - | Integer - milliseconds taken to execute the block | [ 1000 timesRepeat: [ 1 + 1 ] ] timeToRun |
Core.Boolean
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
& aBoolean | Smalltalk | aBoolean Object - the other operand | Object - false when the receiver is false, else aBoolean (ANSI | (3 > 2) & (2 > 1) => true |
| aBoolean | Smalltalk | aBoolean Object - the other operand | Object - true when the receiver is true, else aBoolean (ANSI | (3 > 2) | (1 > 2) => true |
Core.Exception class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
signal: aString | Smalltalk | aString String - exception message | - raises an instance of the receiver class | Exception signal: 'Error occurred' |
, anExceptionSelector | Smalltalk | anExceptionSelector - an exception class or ExceptionSet | ExceptionSet - the receiver and the argument | [1/0] on: ZeroDivide, MessageNotUnderstood do: [:e | 0] |
handles: anException | Smalltalk | - | Boolean - true if anException is an instance of the receiver or a subclass | - |
Core.ExceptionSet
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
, anExceptionSelector | Smalltalk | anExceptionSelector - an exception class or ExceptionSet | ExceptionSet - the receiver's selectors and the argument | [1/0] on: ZeroDivide, MessageNotUnderstood do: [:e | 0] |
handles: anException | Smalltalk | - | Boolean - true if one of the selectors handles anException | - |
Core.Number
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
between: low and: high | Smalltalk | low Number - lower bound (inclusive), high Number - upper bound (inclusive) | Boolean - true if low <= self <= high | 5 between: 1 and: 10 => true |
clampMin: min max: max | Smalltalk | min Number - minimum value, max Number - maximum value | Number - self clamped to [min, max] | 15 clampMin: 0 max: 10 => 10 |
Core.Object
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
= anObject | Smalltalk | anObject Object - the object to compare with | Boolean - numbers, strings, characters and Arrays compare by value, anything else by identity; a class defines = (and hash) to compare its instances by value | 3 = 3.0 |
~= anObject | Smalltalk | anObject Object - the object to compare with | Boolean - (self = anObject) not, so a class that defines = gets ~= too | 3 ~= 4 |
printOn: aStream | Smalltalk | aStream StringStream - the stream to write to | self - writes the receiver's printString; a class defines printOn: to print its instances its own way | Account >> printOn: aStream aStream nextPutAll: 'Account '; print: owner |
displayOn: aStream | Smalltalk | aStream StringStream - the stream to write to | self - writes the receiver's displayString; the same as printOn: unless a class defines displayOn: | 'abc' displayOn: aStream |
printString | Smalltalk | - | String - the text a programmer reads: strings quoted ('abc'), characters with $ ($a), symbols with # (#abc), an instance by its class (an Account) or its printOn: | 'abc' printString => '''abc''' |
displayString | Smalltalk | - | String - the text for a user: a string without quotes, a character without $, anything else its printString | 'abc' displayString => 'abc' |
asString | Smalltalk | - | String - the displayString (a String answers itself, a Symbol its name) | 42 asString => '42' |
printNl | Smalltalk | - | self - writes the printString and a newline to stdout | 'abc' printNl prints 'abc' |
print | Smalltalk | - | self - writes the printString to stdout, no newline | 3 print |
displayNl | Smalltalk | - | self - writes the displayString and a newline to stdout | 'abc' displayNl prints abc |
display | Smalltalk | - | self - writes the displayString to stdout, no newline | 'abc' display |
errorPrintNl | Smalltalk | - | self - writes the printString and a newline to stderr | x errorPrintNl |
errorPrint | Smalltalk | - | self - writes the printString to stderr, no newline | x errorPrint |
errorDisplayNl | Smalltalk | - | self - writes the displayString and a newline to stderr | 'failed' errorDisplayNl |
errorDisplay | Smalltalk | - | self - writes the displayString to stderr, no newline | 'failed' errorDisplay |
error: aString | Smalltalk | aString String - error message | - raises Error exception | self error: 'Something went wrong' |
-> anObject | Smalltalk | anObject Object - the value | Association - self as key, anObject as value | 'name' -> 'John' |
Core.Object class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
basicNew | Smalltalk | - | Object - uninitialized instance | Point basicNew |
new | Smalltalk | - | Object - new initialized instance | Point new |
Core.Path class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
stem: aPath | Smalltalk | aPath String - file path | String - filename without extension | Path stem: 'foo/bar.txt' |
Core.String
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
stripAnsi | Smalltalk | - | String - with ANSI escape sequences removed | 'hello' red stripAnsi |
displayWidth | Smalltalk | - | Integer - display width accounting for full-width chars | 'hello' displayWidth |
splitOn: aDelimiter | Smalltalk | aDelimiter String - delimiter to split on | Array - array of substrings | 'abc' splitOn: '' splits into individual characters |
between: startMark and: endMark | Smalltalk | startMark String - opening marker, endMark String - closing marker | String - substring between the first occurrence of startMark and the next occurrence of endMark after it, or nil if either marker is missing. | 'foo[bar]baz' between: '[' and: ']' => 'bar' |
allBetween: startMark and: endMark | Smalltalk | startMark String - opening marker, endMark String - closing marker | OrderedCollection - all non-overlapping substrings between successive startMark / endMark pairs. Empty if no match. | '[a][b][c]' allBetween: '[' and: ']' |
Core.String class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
join: aCollection with: aDelimiter | Smalltalk | aCollection Collection - elements to join, aDelimiter String - separator between elements | String - joined string | String join: #(a b c) with: ', ' |
Core.StringStream
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
print: anObject | Smalltalk | anObject Object - the object to write | self - writes anObject's printString | aStream print: 42 |
display: anObject | Smalltalk | anObject Object - the object to write | self - writes anObject's displayString | aStream display: name |
Core.Time class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
millisecondsToRun: aBlock | Smalltalk | aBlock Block - block to measure | Integer - milliseconds taken to execute the block | Time millisecondsToRun: [ 1000 timesRepeat: [ 1 + 1 ] ] |
Core.WriteHandle class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
open: path do: aBlock | Smalltalk | path String - file path to write, aBlock Block - block receiving the handle | Object - result of block evaluation; the handle is closed even if the block raises; a file that cannot be opened, written or closed raises an Error with the reason | WriteHandle open: 'out.txt' do: [:h | h writeLine: 'Hello'] |
Dictionary
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
= anObject | Smalltalk | anObject Object - the object to compare with | Boolean - true for a Dictionary with the same keys whose values are = | (Dictionary new at: 1 put: 2; yourself) = (Dictionary new at: 1 put: 2; yourself) |
do: aBlock | Smalltalk | aBlock Block - block for each value | nil | dict do: [:v | v displayNl] |
keysAndValuesDo: aBlock | Smalltalk | aBlock Block - two-arg block [:key :value | ...] | nil | dict keysAndValuesDo: [:k :v | k displayNl] |
hasKey: key | Smalltalk | key Object - key to check | Boolean - true if key exists | dict hasKey: 'name' |
collect: aBlock | Smalltalk | aBlock Block - one-arg block applied to each value | Dictionary - same keys, values replaced by the block results | #{'a' -> 1} collect: [:v | v * 10] |
select: aBlock | Smalltalk | aBlock Block - one-arg predicate on each value | Dictionary - the entries whose value satisfies the block | #{'a' -> 1. 'b' -> 2} select: [:v | v > 1] |
reject: aBlock | Smalltalk | aBlock Block - one-arg predicate on each value | Dictionary - the entries whose value does not satisfy the block | #{'a' -> 1. 'b' -> 2} reject: [:v | v > 1] |
at: key ifAbsent: absentBlock | Smalltalk | key Object - key to look up, absentBlock Block - block if key not found | Object - value or block result | dict at: 'x' ifAbsent: [0] |
at: key ifAbsentPut: aBlock | Smalltalk | key Object - key to look up, aBlock Block - block to compute and store if absent | Object - existing or new value | dict at: 'x' ifAbsentPut: [0] |
at: key add: value | Smalltalk | key Object - bucket key, value Object - element to append | Dictionary - self | methods at: var add: sel |
keyWithValue: targetValue | Smalltalk | targetValue Object - value to search for | Object - first key (by iteration order) whose value = targetValue, or nil if no match. Iteration order is implementation defined; use keysWithValue: when expecting multiple matches. | varToClass keyWithValue: 'String' |
keysWithValue: targetValue | Smalltalk | targetValue Object - value to search for | OrderedCollection - all keys whose value = targetValue. Empty if none match. | varToClass keysWithValue: 'String' |
merge: aDictionary | Smalltalk | aDictionary Dictionary - dictionary to merge into self | Dictionary - self (modified) | dict := Dictionary new at: 'a' put: 1. dict merge: (Dictionary new at: 'b' put: 2) |
keysDo: aBlock | Smalltalk | aBlock Block - one-arg block, called with each key (ANSI 5.7.2.12) | - | - |
keyAtValue: value | Smalltalk | - | Object - a key whose value is equal to value, nil if none (ANSI 5.7.2.8) | - |
Env class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
at: key ifAbsent: aBlock | Smalltalk | key String - environment variable name, aBlock Block - evaluated if variable not found | String or block result | Env at: 'HOME' ifAbsent: ['/tmp'] |
Float
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
integerPart | Smalltalk | - | Float - truncated toward zero, still a Float (ANSI 5.6.2.21) | - |
asFraction | Smalltalk | - | Fraction - the receiver's exact value (every finite Float is a dyadic rational) (ANSI 5.6.2.15) | 0.75 asFraction => (3/4) |
asStringPrecision: n | Smalltalk | n Integer - decimal places | String - formatted with n decimal places | 3.14159 asStringPrecision: 2 => '3.14' |
Integer
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
asFraction | Smalltalk | - | Integer - an integer is its own exact fraction (ANSI 5.6.2.15) | - |
gcd: anInteger | Smalltalk | anInteger Integer | Integer - largest non-negative common divisor; 0 gcd: 0 = 0 (ANSI 5.6.5.12) | 12 gcd: 18 => 6 |
lcm: anInteger | Smalltalk | anInteger Integer | Integer - smallest non-negative common multiple; 0 if either is 0 (ANSI 5.6.5.14) | 4 lcm: 6 => 12 |
even | Smalltalk | - | Boolean - true if even | 4 even |
odd | Smalltalk | - | Boolean - true if odd | 5 odd |
Interval
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
at: index | Smalltalk | index Integer - 1 to size | Number - start + ((index - 1) * step) (ANSI | (10 to: 20 by: 5) at: 2 => 15 |
do: aBlock | Smalltalk | aBlock Block - block to evaluate for each element | nil | (1 to: 5) do: [:x | x displayNl] |
Maybe class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
value: aBlock | Smalltalk | aBlock Block - block to execute in nil-tolerant mode | Object - block result or nil | Maybe value: [dict at: 'key' at: 'sub'] |
Number
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
abs | Smalltalk | - | Number - absolute value | -5 abs |
min: other | Smalltalk | other Number - value to compare | Number - smaller value | 3 min: 5 |
max: other | Smalltalk | other Number - value to compare | Number - larger value | 3 max: 5 |
roundTo: quantum | Smalltalk | quantum Number - rounding precision | Number - value rounded to nearest quantum | 3.14159 roundTo: 0.01 => 3.14 |
reciprocal | Smalltalk | - | Number - 1 / receiver; ZeroDivide for zero (ANSI 5.6.2.29) | 4 reciprocal => (1/4) |
squared | Smalltalk | - | Number - receiver * receiver (ANSI 5.6.2.35) | 3 squared => 9 |
sign | Smalltalk | - | Integer - 1, 0 or -1 (ANSI 5.6.2.33) | -3 sign => -1 |
quo: aNumber | Smalltalk | aNumber Number - divisor | Integer - quotient truncated toward zero (ANSI 5.6.2.26) | -7 quo: 2 => -3 |
rem: aNumber | Smalltalk | aNumber Number - divisor | Number - remainder with the receiver's sign: (a quo: b) * b + (a rem: b) = a (ANSI 5.6.2.30) | -7 rem: 2 => -1 |
asInteger | Smalltalk | - | Integer - the receiver truncated toward zero (rounded is the rounding form) | 3.7 asInteger => 3 |
integerPart | Smalltalk | - | Number - the receiver truncated toward zero, in the receiver's protocol (ANSI 5.6.2.21) | 3.75 integerPart => 3.0 |
fractionPart | Smalltalk | - | Number - receiver - receiver integerPart (ANSI 5.6.2.20; for a negative receiver the standard's two invariants disagree, this keeps integerPart + fractionPart = receiver) | 3.75 fractionPart => 0.75 |
asBytesString | Smalltalk | - | String - human-readable byte size (B/KB/MB/GB/TB) | 1073741824 asBytesString => '1 GB' |
OrderedCollection
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
= anObject | Smalltalk | anObject Object - the object to compare with | Boolean - true for an OrderedCollection of the same size whose elements are = in order | (OrderedCollection new add: 1; yourself) = (OrderedCollection new add: 1; yourself) |
addLast: newElement | Smalltalk | - | Object - newElement, added at the end (ANSI 5.7.18.13) | - |
add: newElement beforeIndex: index | Smalltalk | newElement Object - element to insert, index Integer - 1 to size + 1; size + 1 appends (ANSI 5.7.18.5) | Object - newElement | - |
Point
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
= anObject | Smalltalk | anObject Object - the object to compare with | Boolean - true for a Point with = x and y | (3 @ 4) = (3 @ 4) |
Shell.Sh class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
run: commandString | Smalltalk | commandString String - shell command to execute | Integer - exit code (0 = success). If the shell itself cannot be started, an Error names it and the OS reason | Sh run: 'git status' |
output: commandString | Smalltalk | commandString String - shell command to execute | String - stdout content, whatever the exit code; stderr passes through to this process's stderr. If the shell itself cannot be started, an Error names it and the OS reason | (Sh output: 'echo hello') displayNl |
lines: commandString | Smalltalk | commandString String - shell command to execute | Array - array of output lines | (Sh lines: 'ls') do: [:l | l displayNl] |
success: commandString | Smalltalk | commandString String - shell command to execute | Boolean - true if exit code is 0 (a command the shell cannot find is a non-zero exit, so false) | (Sh success: 'test -f README.md') ifTrue: ['exists' displayNl] |
String
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
red | Smalltalk | - | String - red colored text | 'error' red |
green | Smalltalk | - | String - green colored text | 'ok' green |
yellow | Smalltalk | - | String - yellow colored text | 'warning' yellow |
blue | Smalltalk | - | String - blue colored text | 'info' blue |
bold | Smalltalk | - | String - bold text | 'important' bold |
underline | Smalltalk | - | String - underlined text | 'link' underline |
first | Smalltalk | - | Character - the first character, nil when the string is empty (as Array first) | 'abc' first => $a |
last | Smalltalk | - | Character - the last character, nil when the string is empty (as Array last) | 'abc' last => $c |
reversed | Smalltalk | - | String - characters in reverse order | 'abc' reversed => 'cba' |
lines | Smalltalk | - | Array - array of lines; a line ends at LF, CRLF or CR, and the terminator is not part of the line (Windows command output is CRLF) | 'a\\r\\nb\\nc' lines |
words | Smalltalk | - | Array - array of words split by whitespace | 'hello world' words |
isBlank | Smalltalk | - | Boolean - true if empty or whitespace only | ' ' isBlank |
trimLeft | Smalltalk | - | String - with leading whitespace removed | ' hello' trimLeft |
trimRight | Smalltalk | - | String - with trailing whitespace removed | 'hello ' trimRight |
includes: aString | Smalltalk | aString String - substring to find | Boolean - true if substring exists | 'hello world' includes: 'wor' |
replaceRegex: pattern do: aBlock | Smalltalk | pattern String - regex pattern with capture groups, aBlock Block - receives the Dict of the match's parts ('match' is the whole match, '1', '2', ... the groups, as in matchGroups:), returns the replacement string | String - with every match replaced by the block's result | 'hello123world456' replaceRegex: '([0-9]+)' do: [:g | '[' , (g at: '1') , ']'] |
format: collection | Smalltalk | collection Array - values to substitute | String - with {1}, {2}, etc replaced | 'Hello {1}!' format: #('World') |
truncateDisplay: maxWidth | Smalltalk | maxWidth Integer - maximum display width | String - truncated string fitting within maxWidth | 'Hello World' truncateDisplay: 5 |
fitDisplay: width | Smalltalk | width Integer - target display width | String - truncated and padded string of exact display width | 'Hi' fitDisplay: 10 |
sameAs: aString | Smalltalk | aString String - string to compare | Boolean - true if the two collate the same; LST's collation ignores case (ANSI 5.7.10.14) | 'Hello' sameAs: 'hello' => true |
subStrings: separators | Smalltalk | separators String - the separator characters (or any collection of Characters) | Array - the runs of characters between separators, empty runs dropped (ANSI 5.7.10.15) | 'a, b,,c' subStrings: ', ' => #('a' 'b' 'c') |
String class
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
with: aCharacter | Smalltalk | aCharacter Character - the string's one character | String - a string of that one Character (ANSI | String with: $a => 'a' |
Text.TablePrinter
| Method | Type | Parameters | Returns | Example |
|---|---|---|---|---|
alignments: anArray | Smalltalk | anArray - Array of alignment symbols (#left, #right, #center) | self | table alignments: #(#left #right #left) |
maxWidths: anArray | Smalltalk | anArray - Array of max column widths (0 = no limit) | self | table maxWidths: #(32 60 40) |
alignmentAt: index | Smalltalk | index - Column index (1-based) | Symbol - alignment for the column (#left, #right, or #center) | - |
padCell: aString width: aWidth alignment: anAlignment | Smalltalk | aString - Cell content, aWidth - Target width, anAlignment - Alignment symbol (#left, #right, #center) | String - padded and truncated string | - |
tools/generate_api_grammar.stにより生成