Stdlib index
- Captured-borrow migration worklist (3.3.3)
- Owned-bind migration worklist (8.2.7)
- Return-side title audit — the ride-through enumeration
- stdlib ownership audit
- stdlib ownership dispositions (plan 1.3.1 / 4.3.1)
aot
codec
codec / csv
codec / json
collection
- ArrayList
- BPlusTree
- Cache
- Collectors
- HashMap
- HashSet
- Heap
- ImmutableList
- ImmutableMap
- ImmutableSet
- LinkedList
- RedBlackTree
- Sort
collection / ltm
concurrent
error
- Exception
- NoOptionalValueException
- NotProvidedException
- RecoverableException
- ScopedBuildFailedException
- ScopeNotActiveException
- Throwable
- UnrecoverableException
gfx
hash
ifx
io
io / file
io / net
io / net / dns
io / net / uri
lang
lang / stream
math
math / fft
math / linalg
math / npio
math / poly
math / random
math / stats
nucleo
- Columns — the Arrow-laid-out substrate
- Fused tensor expressions — Fuse
- Table — the lazy, typed dataframe
- Tape — define-by-run autograd
- Transform intrinsics — Grad, Vmap, Jit
process
reflect
search / distance
search / fuzzy
search / ngram
session
time
- Clock
- DateTimeFormatter
- Duration
- Instant
- LocalDate
- LocalDateTime
- LocalTime
- Period
- ZonedDateTime
- ZoneId
- ZoneOffset
wire
xpu
xpu / mesh
Optional<T>
cajeta.lang.Optional — value-typed sum: present or empty. Stack-allocated by
default; T may be any type — primitive, class reference, struct, even
another Optional. The v1 surface is the minimal Java-style core: construction
via the constructor, inspection (isPresent / isEmpty), extraction (get /
orElse). get() on an empty Optional throws
NoOptionalValueException
(recoverable — catchable by type); guard with isPresent() or use
orElse() when a fallback exists.
Optional<int32> hit = stack Optional<int32>(true, 42);
Optional<int32> miss = stack Optional<int32>(false, 0);
if (hit.isPresent()) {
int32 v = hit.get(); // 42
}
int32 fallback = miss.orElse(-1); // -1
Methods
| Signature | |
|---|---|
Optional(boolean present, #T value) ⚑ | Build an Optional directly: true with the held value, or false for empty (the value slot is still consumed — pass a zero/default) |
boolean isPresent() | True when a value is held |
boolean isEmpty() | True when empty |
T get() | Extract the value; throws NoOptionalValueException when empty |
T orElse(T fallback) | The held value when present, otherwise fallback |
⚑ = @EntryPoint
See also
- Tour: AsyncDemo, ConcurrentDemo
- Source:
runtime/src/cajeta/lang/Optional.cajeta - Stream —
next()andfindFirstyield Optionals