tag:blogger.com,1999:blog-34374221.post2791828516361573567..comments2024-03-03T07:35:45.002+01:00Comments on geekAbyte: An easier way to interpret code blocks and curly braces in Scaladadehttp://www.blogger.com/profile/01934137473204182228noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-34374221.post-63406528308646803502022-03-15T15:29:28.452+01:002022-03-15T15:29:28.452+01:00very useful, thank you!very useful, thank you!Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-34374221.post-22467953639281776152018-03-14T13:28:14.367+01:002018-03-14T13:28:14.367+01:00But why would you even want to call that using the...But why would you even want to call that using the curly braces? The x => (x + 4).toString expression is one single line, so no need for that, thus it should be called like this:<br /><br />foo(1)( x => (x + 4).toString )(println)<br /><br />You use the {} braces when you have expressions that span multiple lines. In such situations, then I have found it useful to focuse on the code in the curly braces, ie the multiple line expression, while viewing whatever comes before as some form of annotations that modifies of influences the value the code in the braces expresses too. <br /><br />Also, I mentioned this interpretation can be overstretched. So if you see a situation where it does not apply, then do not force it.<br /><br />I have, personally found this very useful. If you find it confusing, then, by all means, do not use it.<br />dadehttps://www.blogger.com/profile/01934137473204182228noreply@blogger.comtag:blogger.com,1999:blog-34374221.post-88171644926456853272018-03-14T09:58:19.551+01:002018-03-14T09:58:19.551+01:00Maybe I'm simply used to the syntax but I just...Maybe I'm simply used to the syntax but I just see them as arguments.<br /><br />A method defined as<br /><br />def foo(a: Int)(b: Int => String)(c: String => Unit)<br /><br />is called like foo(1){ x => (x + 4).toString }(println)<br /><br />I think the annotation part you're talking of just make things more confusing.Anonymousnoreply@blogger.com