[Pas2js] The operator ??

Michael Van Canneyt michael at freepascal.org
Sat Dec 22 14:58:54 CET 2018



Because pascal has no null or undefined,  I see no value in this.

But when ternary operators arrive, you can use that. 
(x ?? 1) is just a shorthand for (x != null ? x : 1)

I wish to repeat that the goal of pas2js is to make pascal available in the
browser.

The goal is not to make pascal resemble Javascript.

Michael.

On Sat, 22 Dec 2018, warleyalex via Pas2js wrote:

> So for example let’s consider the nullable float value x in the following
> example;
> If it is specified it will print its value, otherwise it will print "‘1".
>
> ---// the special operator ?? //----------------------
> var
>  x: JSValue;
> begin
>  console.log(x ?? 1);
> end;
> ------------------------------
>
> //------- JS output : The operator ?? translates to something like: 
> //--------
> var x;
>   console.log(x||1);
> --------------------------------
>
>
>
>
>
>
> --
> Sent from: http://pas2js.38893.n8.nabble.com/
> _______________________________________________
> Pas2js maillist  -  Pas2js at lists.freepascal.org
> http://lists.freepascal.org/cgi-bin/mailman/listinfo/pas2js


More information about the Pas2js mailing list