GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Processing
  • Download
  • Reference
  • Environment
  • Libraries
  • Tools
  • Wiki
  • Tutorials
  • Examples
  • Books
  • Forum
  • Overview
  • People
  • Privacy

This view

  • Original page
  • New address

GeezerVison is showing processing.org — else / Reference

Reference+
Documentation→Reference→Control→Conditionals

Name

else

Description

Extends the if structure allowing the program to choose between two or more blocks of code. It specifies a block of code to execute when the expression in if is false.

Examples

  • size(400, 400);
    
    for (int i = 20; i < 380; i += 20) {
      if (i < 140) {
        line(120, i, 320, i);
      } else if (i < 260) {
        line(80, i, 360, i);
      } else {
        line(0, i, 400, i);
      }
    }
  • size(400, 400);
    
    for (int i = 20; i < 380; i += 20) {
      if (i < 140) {
        line(120, i, 320, i);
      } else {
        line(80, i, 360, i);
      }
    }

Syntax

  • if (expression) {
  • statements
  • } else {
  • statements
  • }
  • if (expression) {
  • statements
  • } else if (expression) {
  • statements
  • } else {
  • statements
  • }

Parameters

  • expressionany valid expression that evaluates to true or false
  • statementsone or more statements to be executed

Related

  • if
Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.