英語版
このページの英語版を見る
dmd.root.optional
オプション型」の実装
Authors:
License:
ソース root/optional.d
Examples:
import core.exception : AssertError; Optional!int opt; assert( opt.isEmpty()); assert(!opt.isPresent()); assert(!opt.hasValue(1)); assert(!opt.hasValue(2)); bool caught; try cast(void) opt.get(); catch (AssertError) caught = true; assert(caught); opt = Optional!int(1); assert(!opt.isEmpty()); assert( opt.isPresent()); assert( opt.get() == 1); assert( opt.hasValue(1)); assert(!opt.hasValue(2));
- struct
Optional
(T); - empty 、または "型"の値を含むオプションの型。T
- this(T
value
);
static Optional!Tcreate
(Tval
); - 与えられた値でOptional 。
- const bool
isPresent
(); - Returns:このOptional が値を含むかどうか。
- const bool
isEmpty
(); - Returns:このOptional が値を含まないかどうか。
- inout inout(T)
get
(); - Returns:値がある場合はその値
- const bool
hasValue
(const Texp
); - Returns:このOptional 、提供された値を含むかどうか。
Copyright © 1999-2024 by the D Language Foundation
DEEPL APIにより翻訳、ところどころ修正。
このページの最新版(英語)
このページの原文(英語)
翻訳時のdmdのバージョン: 2.108.0
ドキュメントのdmdのバージョン: 2.109.1
翻訳日付 :
HTML生成日時:
編集者: dokutoku