Object0.26.1
expand_more
abstract external class Object extends Any
- Known subtypes:
- AbstractDateTime, AbstractStep, AgentConfig, AlertManagerConfig, AlertingConfig, AlertingRule, AlertingRuleGroup, AlsoKnownAs, Annotation, AnnotationNode, AppEnvCluster, AttachWorkspaceStep, BaseParameter, BasicAuth, Benchmark, Benchmark, BenchmarkReport, BenchmarkResult, BinaryOperatorExpressionNode, BuiltInKeywordExpressionNode, BuiltInTypeNode, CData, Checksums, Class, ClassExtendsClause, ClassHeader, ClassNode, ClassOrModuleNode, CoerceFailure, Column, Command, Comment, Components, Config, Configuration, ConstrainedTypeNode, Contact, Coralogix, CpuInput, CsvInputDataFormat, Date, DateTime, Declaration, DeclaredType, DeclaredTypeNode, Deprecated, DiscardOutput, Discriminator, DiskInput, DnsSdConfig, DocCommentNode, DocExample, DocPackageInfo, DockerImage, DocsiteInfo, Document, Documentation, Dynamic, Editor, Encoding, EvaluatorSettings, Example, ExecInput, Executor, ExpressionNode, ExtVar, ExternalDocs, ExternalDocumentation, Failure, Field, FileInput, FileOutput, FileOutput, FileSdConfig, FilterSpec, FunctionType, FunctionTypeNode, Generator, GeneratorSettings, GlobalConfig, HTTPResponse, Header, Http, HttpInput, IfElseExpressionNode, ImportExpressionNode, ImportStr, Info, Inline, Input, InputDataFormat, Inputs, Job, JobFilters, JsonInputDataFormat, JsonOutputDataFormat, JsonRenderer, JsonSchema, JsonStructTag, KubernetesSdConfig, KubernetesSdConfigSelector, Language, License, Link, Listing, LiteralValueExpressionNode, LogicStatement, MacOSExecutor, Machine, Mapping, Match, MediaType, MemberAccessExpressionNode, MetadataConfig, Method, MethodNode, MethodParameter, Microbenchmark, Module, Module, ModuleInfo, ModuleOutput, ModuleType, ModulesGenerator, Name, NamespaceSpec, NetInput, NothingType, NullableType, NullableTypeNode, OAuthFlow, OAuthFlows, ObjectExpressionNode, OpenTelemetry, OpenTelemetryOutput, OperatingSystem, Operation, Orb, Output, OutputBenchmark, OutputDataFormat, Outputs, PListRenderer, Package, Package, PackageDependency, Parameter, Parameter, Parser, Parser, Parser, ParserBenchmark, PathItem, PcfRenderDirective, PcfRenderer, PersistToWorkspaceStep, PipelineValues, Platform, Plugin, PostfixOperatorExpressionNode, PrefixOperatorExpressionNode, Processor, Processor, Processors, Project, PrometheusClientOutput, PrometheusInput, PrometheusObject, Properties, PropertiesBase, PropertiesRenderer, Property, PropertyDefinitionNode, PropertySchema, Proxy, QualifiedMemberAccessExpressionNode, QueueConfig, ReadExpressionNode, ReadFailure, RecordingRule, RecordingRuleGroup, Reference, Regex, RegexMatch, RelabelConfig, Release, RemoteDependency, RemoteReadConfig, RemoteWriteConfig, RenderDirective, Renderer, Renderer, Renderer, Renderer, RequestBody, Reserved, Resource, Response, RestoreCacheStep, Rule, RunStep, Runtime, SaveCacheStep, ScheduleTrigger, ScheduleTriggerFilter, ScheduleTriggerFilterBranches, Schema, SchemaGenerator, ScrapeConfig, Security, SecurityScheme, Server, ServerVariable, SetupRemoteDockerStep, Sigv4Config, Since, SocketListenerInput, SolrInput, SourceCode, SourceCode, SourceLocation, StandardLibrary, StarlarkProcessor, StaticConfig, StoreArtifacts, StoreTestResults, StringExpressionNode, StringLiteralType, StringLiteralTypeNode, SubscriptExpressionNode, SuperAccessExpressionNode, SuperSubscriptExpressionNode, TLSConfig, TableRenderer, TableStyle, Tag, TailInput, Telegraf, Time, TraceExpressionNode, Type, Type, TypeAlias, TypeAliasNode, TypeAnnotationNode, TypeDeclaration, TypeNode, TypeParameter, TypeVariable, Typed, UnionType, UnionTypeNode, UnknownType, UnlessStep, Unlisted, ValueRenderer, VarArgs, Version, VirtualMachine, WhenStep, Workflow, WorkflowJob, Xml, YamlRenderer, base, convert, deepToTyped, expressions, generate, generate, go, json, jsonnet, math, operators, platform, protobuf, reflect, release, semver, settings, shell, structuredRead, table, test, toml, utils, utils, xml, yaml
- Known usages:
- All versions:
- 0.29.0-dev, 0.28.1, 0.28.0, 0.28.0-dev, 0.27.2, 0.27.1, 0.27.0, 0.26.3, 0.26.2, 0.26.1, 0.26.0, 0.25.3, 0.25.2, 0.25.1, 0.25.0-dev
obj = new {
name = "Pigeon" // property
"Hello" // element
["two"] = 2 // entry
}
obj.name // "Pigeon"
obj[0] // "Hello"
obj["two"] // 2
An object can be amended to create variants of itself. This is similar to inheritance in prototype-oriented programming.
pigeon = new { name = "Pigeon"; age = 42 }
barnOwl = (pigeon) { name = "Barn Owl" } // override property `name`
oldPigeon = (pigeon) { age = 84 } // override property `age`
Object members may reference other members:
thresholds = new { lower = 10; upper = lower + 5 }
Object members are dynamically bound. This is similar to how computed cells in a spreadsheet work.
thresholds = new { lower = 10; upper = lower + 5 }
thresholds2 = new { lower = 7 } // thresholds2.upper == 12
Objects have memberwise equality and hash code.
To arbitrarily manipulate an object, convert it to a Collection
.
If necessary, the manipulated Collection
can be converted back to an Object
.
pigeon = new { name = "Pigeon"; age = 42 }
manipulated = pigeon.toMap().mapKeys((key, value) -> key.reverse())
manipulated.toDynamic() // new { eman = "Pigeon"; ega = 42 }
A composite value containing members (properties, elements, entries).