digitalmars.D.learn - Why is typeof(readln) -> void?
- blizzard (10/10) Jul 18 2020 ```
- rikki cattermole (5/7) Jul 18 2020 The brackets are optional when calling a function. You are not calling a...
``` import std.stdio; void main() { writeln(typeof(readln()).stringof); // string writeln(typeof(readln).stringof); // void } ``` Can anybody explain the difference between readln() and readln? I read somewhere that the () were optional, so why this difference?
Jul 18 2020
On 18/07/2020 9:14 PM, blizzard wrote:Can anybody explain the difference between readln() and readln? I read somewhere that the () were optional, so why this difference?The brackets are optional when calling a function. You are not calling a function if you wrap it in typeof. "The Expression is not evaluated, it is used purely to generate the type:" https://dlang.org/spec/declaration.html#Typeof
Jul 18 2020