More on Rust

Jesse Phillips jessekphillips+D at gmail.com
Thu Feb 10 08:33:07 PST 2011


Jean Crystof Wrote:

> How about this?
> spir Wrote:
> 
> auto x =
>   if (localtime().hours>= 8) {
>     "awake!"
>   } else {
>     "asleep, go away."
>   };
> 
> log "I'm " + x;
> 
> I think it solves the problem of unkown type for x nicely. And it's very close to what we already have. something ? foo : bar might do the same, but if() [} else {} is much more readable IMO.

Humm, what we currently have:

auto x = {
       if (localtime().hours>= 8) {
          "awake!"
       } else {
          "asleep, go away."
        };
   }();
 
log "I'm " + x;


More information about the Digitalmars-d mailing list