This compiles fine:
static CatalogNode? findNode(CatalogNode[] rootNodes, Str nodeGuid) { return rootNodes.eachWhile |CatalogNode node| { findANode(node, nodeGuid) } }
This doesn't (compiler says Cannot return netColarCrmCat::CatalogNode? as sys::Void)
Cannot return netColarCrmCat::CatalogNode? as sys::Void
static CatalogNode? findNode(CatalogNode[] rootNodes, Str nodeGuid) { return rootNodes.eachWhile |CatalogNode node| { echo("hello") return findANode(node, nodeGuid) } }
Figure it out
static CatalogNode? findNode(CatalogNode[] rootNodes, Str nodeGuid) { return rootNodes.eachWhile |CatalogNode node -> CatalogNode?| { echo("hello") return findANode(node, nodeGuid) } }
I believe the way closure type inference works today is that all the parameters must have unspecified types if you wish to infer the return type. Not sure that is really the best rule
Login or Signup to reply.
tcolar Wed 11 Nov 2009
This compiles fine:
This doesn't (compiler says
Cannot return netColarCrmCat::CatalogNode? as sys::Void
)tcolar Wed 11 Nov 2009
Figure it out
brian Wed 11 Nov 2009
I believe the way closure type inference works today is that all the parameters must have unspecified types if you wish to infer the return type. Not sure that is really the best rule