[Grace-core] Types of blocks

James Noble kjx at ecs.vuw.ac.nz
Tue Aug 23 16:59:13 PDT 2011


So I typed versions of these at Scala: 

basically those that worked all go to Any (their top type)

>  { (a : String, b : Boolean, c : Boolean) => if (b) { a } else { a.size } }
> res5: (String, Boolean, Boolean) => Any = <function3>
> 
>  { (a : String, b : Boolean, c : Boolean) => if (c) { return a } else if (b)  { a } else { a.size } }
> could't get this one to work - return has to be in a method, and then scala says:
> <console>:5: error: method foo has return statement; needs result type
> 
> the very similar is the same as the first case:
>  { (a : String, b : Boolean, c : Boolean) => if (c) { a } else if (b) { a } else { a.size } }
> res7: (String, Boolean, Boolean) => Any = <function3>
> 
> (a : String, b : Boolean, c : Boolean) => if (c) { var b1 = c } else {if (b)  { a } else { a.size }}
> res9: (String, Boolean, Boolean) => Any

J


More information about the Grace-core mailing list