> doubler2 is a partial function because it is not defined for all the inputs. If we pass in 5, it won’t return any value.

That's wrong. `doubler2` is defined for all the inputs, it just returns `null` for some of them, which is totally valid output. It would be partial if it were implemented like that:

int doubler2(int value) {

if (value == 1) return 2;

if (value == 2) return 4;

if (value == 3) return 6;

throw ArgumentError();

}

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Kirill Bubochkin
Kirill Bubochkin

Responses (1)

Write a response