> The "??" operator is used in TypeScript, JavaScript, C# and a few other
>
> languages.
Oh ok, fair enough, thanks. Shows how much I know :) I’d never seen it before.
> On 5 Oct 2020, at 14:20, Bram Moolenaar wrote:
>
>
>>> var name = Getname() ?? 'unknown'
>>
>> This `??` operator seems a
> > var name = Getname() ?? 'unknown'
>
> This `??` operator seems a bit unique to vim9script. If we're trying to be
> more like other languages how about either re-using `else` (as in Getname()
> else 'unknown') or using `or` (Like python): `Getname() or "unknown"`
Python operators are word
Dominique wrote:
> Bram Moolenaar wrote:
>
> > For the first example, we can use a new operator which is specifically
> > for testing an expression to be falsy and using a replacement:
> >
> > var name = Getname() ?? 'unknown'
> >
> > Let me know if you have comments.
>
> This is know
Bram Moolenaar wrote:
> For the first example, we can use a new operator which is specifically
> for testing an expression to be falsy and using a replacement:
>
> var name = Getname() ?? 'unknown'
>
> Let me know if you have comments.
This is known as the 'elvis operator', which exists
> var name = Getname() ?? 'unknown'
This `??` operator seems a bit unique to vim9script. If we're trying to be
more like other languages how about either re-using `else` (as in Getname()
else 'unknown') or using `or` (Like python): `Getname() or "unknown"`
On Sunday, October 4, 2020 at 10:47:
> In javascript you can use !! operator to always convert it to boolean.
>
> var name = ''
> var nameExists = !!(name || 'Prabir')
Yes, and I think we should do the same. It should already work like
that now.
Thus in most places where a condition is expected, such as with ":if"
and ":while",
In javascript you can use !! operator to always convert it to boolean.
var name = ''
var nameExists = !!(name || 'Prabir')
On Saturday, October 3, 2020 at 12:25:21 PM UTC-7 Andy Wokula wrote:
> Am 03.10.2020 um 17:44 schrieb Bram Moolenaar:
> > Therefore, I'm going to make && and || have a boole
Am 03.10.2020 um 17:44 schrieb Bram Moolenaar:
Therefore, I'm going to make && and || have a boolean result again.
I think that is the easiest to understand, and what most languages do.
+100
--
Andy
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply
As a first approach I have used what TypeScript does. However,
considering the feedback I have received, it's not very consistent and
has a few surprising sides.
One thing is that the "||" and "&&" operators do not result in a boolean
true or false, but the argument value. This is nice for som