I just wanted to pause in an F# console application, so I wrote:
Console.ReadKey()
But this gives the warning: This expression should have type 'unit', but has type 'ConsoleKeyInfo'.
What can I do to fix this?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Solution:
Explanation:
Console.ReadKey()returns an object of type ‘ConsoleKeyInfo’ but you’re using it as a statement without assigning the return value to anything. So F# warns you that you’re ignoring a value.ignoretakes any type and returns nothing. It could be defined like this: