You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Db.fetch()
.start("n=node(2)")
.match("(n)-[r:KNOWS]->(c)")
.return "n"
.on (data) -> console.log data # omitting () since it's the last method call
Make cleaner code:
However, since I am using the dot (.), a new line and indentation, couldn't all the () be removed like this:
Db.fetch
.start "n=node(2)"
.match "(n)-[r:KNOWS]->(c)"
.return "n"
.on (data) -> console.log data
Often when we do chaining we will begin each method call in a new line and indent so the methods are aligned.
Change faster:
And since sometimes the method calls' position change the logic, I move them around.
Db.fetch()
.on (data) -> console.log data # will break
.start("n=node(2)")
.match("(n)-[r:KNOWS]->(c)")
.return("n")
But this wouldn't work since the last method call doesn't need a () so when I moved it up I now have to add the ().
This is forcing me to add () to the last call every time so we can change the order quickly. There are better examples where you wanna move the lines up and down to adjust the logic.
Single line:
I think using the dot (.) is sufficient to tell it's a chaining call. This could even be used as a one liner?
Db.fetch .start "n=node(2)" .match "(n)-[r:KNOWS]->(c)" .return "n" .on (data) -> console.log data
Parseable:
If somehow the dot isn't enough we have the new line and indentation as a confirmation that it's a chaining method call.
Another example:
I usually write a method call with arguments like this:
db.print "hello"
But then I have to chain and have to go back and change it to:
In these two examples you can clearly see why I am "forced" to just use () in the last method call in the beginning so I don't have to add them later when I need to chain. But that kinda defeats the purpose of not having to use () in the last method call. "You can, but I wouldn't". Also I can't omit the () in the middle layer method calls.
Benefits of the nicer syntax:
more clean code
type/chain faster
don't have to change anything already there
I think this is doable and will give a better user experience.
Thoughts?
The text was updated successfully, but these errors were encountered:
This has been brought up a few times before. I think #1495 has the most recent discussion of the issue. #1889 has a similar proposal that would probably include a feature like this.
There was another issue that suggested the one-liner form, but I can't find it#1407. I'm not sure I'm quite so keen on that form, though.
I usually do like this:
Make cleaner code:
However, since I am using the dot (.), a new line and indentation, couldn't all the () be removed like this:
Often when we do chaining we will begin each method call in a new line and indent so the methods are aligned.
Change faster:
And since sometimes the method calls' position change the logic, I move them around.
But this wouldn't work since the last method call doesn't need a () so when I moved it up I now have to add the ().
This is forcing me to add () to the last call every time so we can change the order quickly. There are better examples where you wanna move the lines up and down to adjust the logic.
Single line:
I think using the dot (.) is sufficient to tell it's a chaining call. This could even be used as a one liner?
Parseable:
If somehow the dot isn't enough we have the new line and indentation as a confirmation that it's a chaining method call.
Another example:
I usually write a method call with arguments like this:
But then I have to chain and have to go back and change it to:
And again:
It would be better to just allow me to:
or as a one liner:
Issues:
In these two examples you can clearly see why I am "forced" to just use () in the last method call in the beginning so I don't have to add them later when I need to chain. But that kinda defeats the purpose of not having to use () in the last method call. "You can, but I wouldn't". Also I can't omit the () in the middle layer method calls.
Benefits of the nicer syntax:
I think this is doable and will give a better user experience.
Thoughts?
The text was updated successfully, but these errors were encountered: