How to reverse char[]?

Steven Schveighoffer schveiguy at yahoo.com
Wed Feb 8 06:56:17 PST 2012


On Wed, 08 Feb 2012 04:30:04 -0500, Jos van Uden <user at domain.invalid>  
wrote:

> On 8-2-2012 2:36, Timon Gehr wrote:
>
>> char[] is handled by Phobos as a range of dchar, ergo it does not have
>> swappable elements.
>
> I'm surprised that array.reverse does work (using 2.057)

array.reverse is *not* the same as reverse(array).  The former is a  
compiler-builtin property for all arrays (the compiler believes that  
anything of the form T[] is an array, even if it's a narrow-width string  
type), and the latter is a range function.

D will continue to trip over itself and fall into newbies until it makes a  
decision to make strings not also be arrays.

-Steve


More information about the Digitalmars-d-learn mailing list