Skip to content

Instantly share code, notes, and snippets.

@chiquitinxx
Last active November 25, 2016 23:38
Show Gist options
  • Save chiquitinxx/296ec6cd0cf4d5afe01e6693f14a877b to your computer and use it in GitHub Desktop.
Save chiquitinxx/296ec6cd0cf4d5afe01e6693f14a877b to your computer and use it in GitHub Desktop.
// Elixir ideas https://quickleft.com/blog/pattern-matching-elixir/
class Functions {
@When('!list')
int length(List list) { 0 }
@When('[heal | tail] = list')
int length(List list) { 1 + length(tail) }
@When('x > 0')
boolean isGreaterThanZero(x) { true }
//Rest of cases
boolean isGreaterThanZero(x) { false }
@When('!file || !new File(path).exists()')
void processFile(String path) { println 'Not exists' }
void processFile(String path) {
//do stuff
}
@When('{false, _} = {isAuthorized, data}')
boolean validForm(boolean isAuthorized, Map data) { false }
@When('{true, Countries.SPAIN} = {isAuthorized, data.country }')
boolean validForm(boolean isAuthorized, Map data) {
//do spanish stuff
}
//.. rest of countries
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment