www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Syntax of...

reply Justin P. <j20513831 gmail.com> writes:
Where, in the documentation, might I find an understanding behind 
the following, syntactically:
auto result = ["whoami"].execute
I believe, I understand `auto,' but of calling execute() on an 
array of strings..?
Apr 11
next sibling parent reply Serg Gini <kornburn yandex.ru> writes:
On Saturday, 11 April 2026 at 21:01:33 UTC, Justin P. wrote:
 Where, in the documentation, might I find an understanding 
 behind the following, syntactically:
 auto result = ["whoami"].execute
 I believe, I understand `auto,' but of calling execute() on an 
 array of strings..?
https://dlang.org/library/std/process/execute.html It is just UFCS which allows instead of: ```d func(params) ``` write it in version: ```d params.func ``` So in D (as it is very Elegant) you can write: ```d 4.writeln ``` and it will print "4"
Apr 11
parent reply Justin P. <j20513831 gmail.com> writes:
On Saturday, 11 April 2026 at 22:12:37 UTC, Serg Gini wrote:
 On Saturday, 11 April 2026 at 21:01:33 UTC, Justin P. wrote:
 Where, in the documentation, might I find an understanding 
 behind the following, syntactically:
 auto result = ["whoami"].execute
 I believe, I understand `auto,' but of calling execute() on an 
 array of strings..?
https://dlang.org/library/std/process/execute.html It is just UFCS which allows instead of: ```d func(params) ``` write it in version: ```d params.func ``` So in D (as it is very Elegant) you can write: ```d 4.writeln ``` and it will print "4"
When operating on an array, can I assume that it will return an array?:: auto x=["who","whoami"].execute
Apr 11
parent Sergey <kornburn yandex.ru> writes:
On Saturday, 11 April 2026 at 23:06:21 UTC, Justin P. wrote:
 When operating on an array, can I assume that it will return an 
 array?:: auto x=["who","whoami"].execute
mm no.. it doesn't matter as function has 2 types `OutType func(InputType x)` You can have different types for input arguments and output arguments.
Apr 12
prev sibling parent Steven Schveighoffer <schveiguy gmail.com> writes:
On Saturday, 11 April 2026 at 21:01:33 UTC, Justin P. wrote:
 Where, in the documentation, might I find an understanding 
 behind the following, syntactically:
 auto result = ["whoami"].execute
 I believe, I understand `auto,' but of calling execute() on an 
 array of strings..?
https://dlang.org/spec/function.html#pseudo-member -Steve
Apr 12