What does q{...} mean?

Dejan Lekic dejan.lekic at gmail.com
Mon Feb 24 15:27:07 PST 2014


Gary Willoughby wrote:

> I keep seeing this syntax used a bit and i'm stumped to what it
> means. What is it?
> 
> enum foo = q{
>     // ???
> };

q{} string literals (so-called "token strings") are a nice D feature - D 
garantees that tokens in between brackets are valid D tokens. This makes 
them perfect for storing D source code. They are quite useful for string 
mixins for an example.

-- 
http://dejan.lekic.org


More information about the Digitalmars-d-learn mailing list