Skip to content

Add a "returns" keyword so that code avoiding implicit returns makes more sense. #3081

@monokrome

Description

@monokrome

There should be a "returns" keyword - or at least some similar concept - so that code avoiding implicit returns makes more sense. Implicit returns still cause a lot of confusions to users of CoffeeScript. This allows us to designate which variable will be returned preemptive to reading the code (which helps readability in many cases) as well as is backwards compatible with implicit returns since this statement is explicit.

One example:

fn = (arg) -> returns result

  result = []

  for i in [1..10]
    result.push(i)

Another example, which beats the return null at the end alternative:

fn = (argA, argB) -> returns null
  arg.push argB

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions