vb.net - VB Recursive Lambda Sub does not compile -
i've created following recursive lambda expression not compile, giving error
type of 'openglobal' cannot inferred expression containing 'openglobal'.
dim openglobal = sub(catalog string, name string) if _globalcomponents.item(catalog, name) nothing dim g new globalcomponent g.open(catalog, name) _globalcomponents.add(g) each gcp globalcomponentpart in g.parts openglobal(gcp.catalog, gcp.globalcomponentname) next end if end sub is i'm trying possible?
the problem type inference. can't figure out type openglobal variable because depends on itself. if set explicit type, might okay:
dim openglobal action(of string, string) = '... this simple test program works expected:
sub main() dim openglobal action(of integer) = sub(remaining integer) if remaining > 0 console.writeline(remaining) openglobal(remaining - 1) end if end sub openglobal(10) console.writeline("finished") console.readkey(true) end sub
Comments
Post a Comment