baseName(path).startsWith(something)

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Jan 9 12:37:38 PST 2014


On Thu, Jan 09, 2014 at 07:06:18PM +0000, monarch_dodra wrote:
> On Thursday, 9 January 2014 at 18:53:58 UTC, Martin Nowak wrote:
> >Neither this
> >
> >if (path.baseName.startsWith(something))
> >    doThis();
> >
> >nor this
> >
> >if (startsWith(baseName(path), something))
> >    doThis();
> >
> >but a combination of the two
> >
> >if (baseName(path).startsWith(something))
> >    doThis();
> >
> >make it possible to write readable sentences.
> >
> >-Martin
> 
> ...is that a question?
> 
> I find the first is most readable. Well, (IMO) with added parens
> too:
> 
> if (path.baseName().startsWith(something))
>     doThis();
> 
> The "standard" one:
> startsWith(baseName(path), something)
> looks just plain horrible (IMO).
> 
> The last one looks... intermediate.

I agree the standard one looks horrible. I actually prefer the last one,
though. It makes it clear what you're passing to startsWith. And AFAICT,
is supported by the current dmd.


T

-- 
Why waste time learning, when ignorance is instantaneous? -- Hobbes, from Calvin & Hobbes


More information about the Digitalmars-d mailing list