
core_functions_unclassified.meta.get.pure Maven / Gradle / Ivy
// Copyright 2022 Goldman Sachs
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import meta::pure::functions::collection::tests::model::*;
native function meta::pure::functions::collection::get(set:T[*], key:String[1]):T[0..1];
function <> meta::pure::functions::collection::tests::get::testGet():Boolean[1]
{
let p = ^CO_NPerson(firstName='Kevin',
lastName='RoeDoe',
locations=[^CO_Location a(place='Jersey City, NJ'),
^CO_Location(place='Philadelphia, PA'),
^CO_Location atx(place='Austin, TX')]);
assertEquals('Austin, TX', $p.locations->get('atx')->toOne().place);
}
function <> meta::pure::functions::collection::tests::get::testGetWithVariable():Boolean[1]
{
let p = ^CO_NPerson(firstName='Kevin',
lastName='RoeDoe',
locations=[^CO_Location jcnj(place='Jersey City, NJ'),
^CO_Location(place='Philadelphia, PA'),
^CO_Location atx(place='Austin, TX')]);
let key = 'atx';
assertEquals('Austin, TX', $p.locations->get($key)->toOne().place);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy