groovy

Add "implies" operator for boolean expressions

Details

  • Type: New Feature New Feature
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: syntax
  • Labels:
    None
  • Number of attachments :
    0

Description

Consider supplying an "implies" operator, often denoted =>, for boolean expressions. Example:

if (itIsRaining => iAmUsingUmbrella) {
  println 'I am dry'
}

itIsRaining => iAmUsingUmbrella is equivalent with !itIsRaining | iAmUsingUmbrella but the "implies" version is in many cases intutively more suitable.

Issue Links

Activity

Hide
blackdrag blackdrag added a comment -

an alternative for a=>b would be !a?:b. Still not as nice of course

Show
blackdrag blackdrag added a comment - an alternative for a=>b would be !a?:b. Still not as nice of course
Hide
Paul King added a comment -

An implies method has been added for 1.8.3 and 1.9, e.g.:

itIsRaining.implies(iAmUsingUmbrella)

Given that the syntax for Java 8 Closures looks to be nearly finalised, we should be able to decide shortly whether a corresponding '=>' operator can also be added. Leaving the issue open for now until that decision is made.

Show
Paul King added a comment - An implies method has been added for 1.8.3 and 1.9, e.g.:
itIsRaining.implies(iAmUsingUmbrella)
Given that the syntax for Java 8 Closures looks to be nearly finalised, we should be able to decide shortly whether a corresponding '=>' operator can also be added. Leaving the issue open for now until that decision is made.

People

Vote (2)
Watch (3)

Dates

  • Created:
    Updated: