Skip to content

Add support for indexing operator [ ] #65

@wgevaert

Description

@wgevaert

CYPHER has the indexing operator [].

Simple examples of its use are WITH {a:'Hello World!'} AS map RETURN map['a'] and WITH ['Hello World!'] AS list RETURN list[0].

More complicated examples are WITH 2 AS a, ['a','b','Hello World!'] AS list RETURN list[a], WITH {a:'Hello World!',c:'a'} AS map RETURN map[map['c']] and
WITH ['a','Hello World!','b'] AS list, {ab:1} AS map RETURN list[map[list[0]+list[2]]]

All of these should return Hello World!

I think [] should be implemented on things of CompositeType and CompositeTypeTrait should have this implemented like ->index($index) where $index is either a string-like thing or integer-like thing. (In particular, lists only accept integers and maps only accept strings if I'm correct).

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions