Page MenuHomeFeedback Tracker

Ternary and Null conditional operators
Feedback, NormalPublic

Description

Hi, i would love for the addition of the Ternary operator

Example:

condition ? trueReturn : falseReturn

It would also be nice to have null conditional operators

A?.B?.Do(C);

if A or B is null it returns early with null and wont error out, this would reduce the null checking bloat that would come with things like

ArmaReforgerScripted game = GetGame();
if (!game) return;

PlayerController  playerController = game.GetPlayerController();
if (!playerController) return;

PlayerCamera playerCamera = playerController.GetPlayerCamera();
if (!playerCamera) return;

IEntity cursorTarget = playerCamera.GetCursorTarget();
if (!cursorTarget) return;

down to just

IEntity cursorTarget = GetGame()?.GetPlayerController()?.GetPlayerCamera()?.GetCursorTarget();
if (!cursorTarget) return;

Details

Severity
Feature
Resolution
Open
Reproducibility
N/A
Operating System
Windows 7
Category
General

Event Timeline

Geez changed the task status from New to Feedback.Thu, Jul 4, 11:32 AM