Introduce SpEL support for syntax like collection?.[expr] for null-safe indexing into lists, arrays, maps, etc.

  • see #21468

Comment From: sbrannen

Hi @Trympyrym,

Congratulations on submitting your first PR for the Spring Framework! 👍

Add to SpEL support for syntax like collection?.[expr] for null-safe get element from lists, arrays, maps, etc

We agree that we should introduce an operator for null-safe indexing; however, we are not yet convinced that ?. should be the syntax for this new operator since the . typically implies some form of property access or method invocation.

In any case, your PR is a great start, and we'll take it from here.

Thanks!

Comment From: sbrannen

Current work on this issue can be viewed in the following feature branch.

https://github.com/spring-projects/spring-framework/compare/main...sbrannen:spring-framework:issues/gh-29847-null-safe-index-operator-in-SpEL

Comment From: sbrannen

This has been merged into main in 9f4d46fe3374cc1e2ca8b2616107680432650a2e and revised/extended in 4d433174eb23b34f514350422b348147b75a314a, d2bd0d57160624f0c5246faa665bb0b882fc431b, 38c473fd055bb9c1f02a49a58c29289a2e32e909, and 218a148898914955bbb8a0abbc190af51dea43c3.

Thanks again for kick-starting this effort! 👍