Logo

Programming-Idioms

  • Dart
  • Java
  • Java
  • Go
  • Lua
  • Python

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)

f = lambda: print('abc')
f()
def finish(name):
    print(f'My job here is done. Goodbye {name}')

Variable name inside curly braces will be replaced by its value. This is called "f-strings" introduced in Python version 3.6
void finish(String name) {
  print("My job here is done. Goodbye $name.");
}
private void methodName() {
	System.out.println("Hello, World!");
}
interface F { void set(); }
F f = () -> out.println("abc");
f.set();
void f() { out.println("abc"); }
void finish(String name){
  System.out.println("My job here is done. Goodbye " + name);
}

void means "no return value".
import "fmt"
finish := func(name string) {
	fmt.Println("My job here is done. Good bye " + name)
}

This is a closure.

finish is a variable of type func(string).
import "fmt"
func finish(name string) {
  fmt.Println("My job here is done. Good bye " + name)
}

There is no return type in the signature, before the { .
function finish(name)
	print('My job here is done. Goodbye, '..name..'.')
end
procedure Finish (Name : String) is
begin
   Put_Line ("My job here is done. Goodbye " & Name);
end Finish;

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