Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8902389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:36:02+00:00 2026-06-15T01:36:02+00:00

Both types Unit and Nothing indicate a function that does not return anything. What’s

  • 0

Both types Unit and Nothing indicate a function that does not return anything. What’s the difference between them?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T01:36:03+00:00Added an answer on June 15, 2026 at 1:36 am

    Unit is a type that has exactly one value ‒ see Unit type. On the other hand, Nothing has no possible value – see Bottom type.

    A function that doesn’t return anything must have the return type Unit. If it were Nothing then the function could not return a result. The only way to exit the function would be by an exception.


    Nothing is used in a different way. It is characterized by two properties:

    1. Nothing is a subtype of every other type (including Null).
    2. There exist no instances of this type.

    When is this useful? Consider None:

    object None extends Option[Nothing]
    

    Because Option is covariant in its type parameter and Nothing is a subtype of everything, Option[Nothing] is a subtype of Option[A] for every type A. So, we can make one object None which is a subtype of Option[A] for every A. This is reasonable, since Nothing cannot be instantiated so Option[Nothing] will always be without a value. Similarly

    object Nil extends List[Nothing]
    

    Unit corresponds to logical true and Nothing corresponds to logical false under the Curry-Howard isomorphism, where we view types as propositions and functions as proofs, .

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a C++ template library that uses both primitive types and pointer
I have some unit tests that run fine on my dev machine on both
I want to test performance of my code on both jvm types -client and
I know C# has both value and reference types, but how can you do
I have two types of data sets. Both are in same size. One contains
I have two user types in my application: Investors and Advisors , they both
I'm using F# and Xunit. (I'm relatively new to both) I've found that when
We use Visual Studio 2010 Ultimate with tests written in MSTest. Both our unit
I have 2 TTreeviews . Both of them have the same number of items.
I have a function that creates a state. A state is defined as: type

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.