Logo

Programming-Idioms

  • Ruby
  • C++

Idiom #3 Create a procedure

Like a function which doesn't return any value, thus has only side effects (e.g. Print to standard output)

#include <iostream>
using namespace std;
void finish(char* name){
    cout << "My job here is done. Goodbye " << name << "\n";
}
def finish( name )
  puts "My job here is done. Goodbye #{name}"
end

Ruby methods always return something; in this case nil, the return value of puts
procedure Finish (Name : String) is
begin
   Put_Line ("My job here is done. Goodbye " & Name);
end Finish;

New implementation...
< >
programming-idioms.org