On 06/03/11 21:02, Marie E. Rognes wrote: > On 03/06/2011 09:30 PM, nore...@launchpad.net wrote: >> if (parameters["max_dimension"].change_count()> 0 >> && V.dim()> max_dimension) >> + { >> return true; >> - >> - // Otherwise, not done. >> - return false; >> + } >> + else >> + return false; >> } > > > I notice that my early returns keep getting moved into else clauses... I > find this approach less readable, especially when there are nested ifs. > Why is it the preferred way? >
Because your comment basically says else, so I'd say it's better to have the code say it consistently. I find it easier to follow, because it's clear that the function exits from the conditional block. The return value is either true or false depending on the one true/false evaluation. Garth > -- > Marie > > _______________________________________________ > Mailing list: https://launchpad.net/~dolfin > Post to : dolfin@lists.launchpad.net > Unsubscribe : https://launchpad.net/~dolfin > More help : https://help.launchpad.net/ListHelp _______________________________________________ Mailing list: https://launchpad.net/~dolfin Post to : dolfin@lists.launchpad.net Unsubscribe : https://launchpad.net/~dolfin More help : https://help.launchpad.net/ListHelp