• Post Reply Bookmark Topic Watch Topic
  • New Topic

Void functions  RSS feed

 
Mohammad Rehan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are all void functions impure functions?
 
Stephan van Hulst
Saloon Keeper
Posts: 7993
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no such thing as a 'void function' in Java.
 
Fred Kleinschmidt
Bartender
Posts: 571
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A pure function (or method) is usually considered to be one that always evaluates to the same value for the same inputs, and does not create any observable side effects.
So what do you think about this:

It always evaluates to the same thing (nothing), and it has no observable side effects. Is it pure or impure?
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Many people would say that a function must return a result, so they regard void function as a contradiction in terms.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!