Logo

Programming-Idioms

  • Java
  • Pascal
  • Dart
  • Ruby
  • Php

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)

function finish($name) 
{
    echo "My job here is done. Goodbye $name";
}
function()
{
    echo "Hello World";
}

This is an unnamed function, it can be bound to a variable or else immediately executed - the demo has both usages in it.
void f() { out.println("abc"); }
interface F { void set(); }
F f = () -> out.println("abc");
f.set();
private void methodName() {
	System.out.println("Hello, World!");
}
void finish(String name){
  System.out.println("My job here is done. Goodbye " + name);
}

void means "no return value".
Procedure finish(name: String);
Begin
  WriteLn('My job here is done. Goodbye ', name);
End;
void finish(String name) {
  print("My job here is done. Goodbye $name.");
}
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