Skip to content

Making objects more chainable #1431

@redalastor

Description

@redalastor

One of the things I really like about jQuery is how everything is chainable.

I like to be able to write:

object.doFoo().doBar().doBaz()

and have all those things done to object. Unfortunately, some libraries don't code that way and I have to do:

object.doFoo()
object.doBar()
object.doBaz()

I could use the with statement but Douglas Crockford wouldn't be happy. I could use a list comprehension but that doesn't seem like a very clean solution.

Could we have some syntax that would let me write something like:

object!.doFoo()
  !.doBar()
  !.doBaz()

And have it rewritten

object.doFoo()
object.doBar()
object.doBaz()

?

That would give us the advantages of the with statement without the drawbacks.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions