Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint

12.8. The $ Operator

Inside index and slice expressions for built-in arrays, D allows the symbol $ to stand in for the length of the array. For example, a[0 .. $ - 1] selects all but the last element of built-in array a.

Although it seems like quite a minor feature, $ has consistently been an important contributor to people’s enjoyment of using D arrays. Conversely, the fact that $ was “magic” and couldn’t be overloaded has been a perennial source of irritation—evidence supporting the view that built-in types should seldom have powers inaccessible to user-defined ones.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial