Real World Snippets

Instinct BDD Framework

Before[17]:

private <T> Collection<Method> findNamedMethods(final Class<T> cls, final NamingConvention namingConvention) {
  final Collection<Method> locatedMethods = new ArrayList<Method>();
  for (final Method method : methodLocator.locate(cls)) {
    if (method.getName().matches(namingConvention.getPattern())) {
      locatedMethods.add(method);
    }
  }
  return locatedMethods;
}
      

After:

def findNamedMethods[T](cls: Class[T], namingConvention: NamingConvention) =
  methodLocator locate(cls) filter (_.getName.matches(namingConvention.getPattern))
      



[17] Courtesy: Tom Adams, Instinct