Proposal: if variable initialization

2018-03-20 Thread Rodrigo
nfortunately Ruby does not limit scope to if, so x "leaks" I think this would be a great and important addition to the language. -Rodrigo PS: Just for the sake of comparison, Perl-style if-assignments could also be an option, albeit a very bad one IMO: if( ( let x = 100 ) > 50 )

Re: Proposal: if variable initialization

2018-03-21 Thread Rodrigo
18 at 04:35 Jordan Harband wrote: >>> >>> Is the use case only ever to capture the thing that serves as the >>> conditional? >>> >>> If so, would perhaps something like `if.value` work better? Since it's a >>> keyword, it could be m

Re: Proposal: if variable initialization

2018-03-21 Thread Rodrigo
Mike Samuel wrote: > > > On Tue, Mar 20, 2018 at 3:57 PM, Rodrigo wrote: >> >> Proposal: inline let/const statements to declare and initialize >> variables within if statements, so that temporary variables exist only >> within the if/else block scope. > >

Re: Proposal: if variable initialization

2018-03-22 Thread Rodrigo
Not just let-scopes, but the introduction of `async/await` also welcomes the introduction of if-scoped variables. if (const data = await collection.find({}).toArray(); data.length > 10) { console.log(data); } else if (data.length > 0) { console.log(data); } else {

Re: Proposal: if variable initialization

2018-03-22 Thread Rodrigo
terminator restriction > before the `else` so it can't be confused with an `else` within an > `if`. > > > - > > Isiah Meadows > m...@isiahmeadows.com > > Looking for web consulting? Or a new website? > Send me an email and we can get started. > www.isiahmeadows.com

Re: Proposal: if variable initialization

2018-03-23 Thread Rodrigo
> > can the iteration operation in the last block, and is simply the last >> > value >> > in the block as-per do expressions. >> > >> > On Thu, 22 Mar 2018 at 15:44 Mike Samuel wrote: >> >> >> >> On Thu, Mar 22, 2018 at 3:50 AM, Isiah Meadows >> >> wrote: >> >>> >> >>> >> >>

A way to prevent properties to be added to an object if they are null or undefined.

2017-11-28 Thread Rodrigo Carranza
A way to prevent properties to be added to an object if they are null or undefined. Currently this can be accomplished in many ways: With an if: ```js function foo(couldBeNull){ let ret = {} if(couldBeNull){ ret.couldBeNull = couldBeNull } return ret } ``` With ternary (kind of gross) ```js fu

Re: A way to prevent properties to be added to an object if they are null or undefined.

2017-11-28 Thread Rodrigo Carranza
It's about the value of the property to be added, nothing to do with the name of the property. It should discard properties whose value are null(but this behavior is not always desired, so a different syntax for these properties should be added). ``` On nov. 28 2017, at 8:33 pm, Sebastian Malt

Re: A way to prevent properties to be added to an object if they are null or undefined.

2017-11-28 Thread Rodrigo Carranza
Yes, like that, but that will require to modify the object. Compare this ```js let a = {} a.field ?= couldBeNull ``` To: ```js let a = { field ?: couldBeNull } ``` Also if you want to set the property with the same name of the variable ```js let field = ... let a = { field? } ``` Why this

Re: A way to prevent properties to be added to an object if they are null or undefined.

2017-11-28 Thread Rodrigo Carranza
Yes, like that, but that will require to modify the object. Compare this ```js let a = {} a.field ?= couldBeNull ``` To: ```js let a = { field ?: couldBeNull } ``` Also if you want to set the property with the same name of the variable ```js let field = ... let a = { field? } ``` Why this

Re: Re%3A A way to prevent properties to be added to an object if they are null or undefined.&In-Reply-To=

2017-11-28 Thread Rodrigo Carranza
Yeah, it was wrong, I'm currently using like ```js let ret = { ... ( couldBeNull ? {couldBeNull} : {} ) } ``` Yours is better and the usual idiom a bit hard to understand. What I'm proposing is something like this ```js let ret = { couldBeNull? } ``` or if you want a different name for the prop

RE: A way to prevent properties to be added to an object if they are null or undefined.

2017-11-28 Thread Rodrigo Carranza
lient and it is acting weird. Also I'm new to mailing lists. De: J Decker Enviado: martes, 28 de noviembre de 2017 09:07 p.m. Para: Michał Wadas Cc: Rodrigo Carranza; es-discuss@mozilla.org Asunto: Re: A way to prevent properties to be added to an object

RE: A way to prevent properties to be added to an object if they are null or undefined.

2017-11-28 Thread Rodrigo Carranza
b.collection('Posts').find({ categoryId?, postType? }) } ``` De: kai zhu Enviado: martes, 28 de noviembre de 2017 11:43 p.m. Para: Rodrigo Carranza Cc: J Decker; Michał Wadas; es-discuss@mozilla.org Asunto: Re: A way to prevent properties to be added to an object if they are null or

RE: A way to prevent properties to be added to an object if they are null or undefined.

2017-11-28 Thread Rodrigo Carranza
> I was about to hit send on a post also suggesting a helper function, but > after thinking about it a bit more, Rodrigo's suggestion resembles extending > the optional chaining proposal > https://github.com/tc39/proposal-optional-chaining

Re: Adding .map() directly to String prototype

2018-05-17 Thread Rodrigo Carranza
In fact there should be a common interface that iterables should implement. I think this could have been proposed before. This way there would be not more common methods proposals. On may. 17 2018, at 10:16 am, Ben Fletcher wrote: Consider adding the array .map() implementation directly to the