Skip to content

Instantly share code, notes, and snippets.

@Walkman100
Last active August 1, 2016 16:41
Show Gist options
  • Save Walkman100/d3da44062d7eebd18548 to your computer and use it in GitHub Desktop.
Save Walkman100/d3da44062d7eebd18548 to your computer and use it in GitHub Desktop.
Formatting
OUTDATED. PLEASE SEE https://walkman100.github.io/formatting
<text>
```java
<code>
```
(Documentation [here](https://guides.github.com/features/mastering-markdown/#GitHub-flavored-markdown))

OUTDATED. PLEASE SEE gists/If Statements.md

VB.Net

Method one:

If [Not] <variable> = <value> Then
    <code>
ElseIf <variable> = <value>
    <code>
Else
    <code>
End If

Method two: (One line)

If <variable> = <value> Then <code> Else <code>

Method three:

If <variable> = <value> Then : <code>
Else : <code>
End If

Java

(! is used for Not instead of the first =)

if (<variable> [!|=]= <value>);
{
    <code>;
}
else if(<variable> == <value>);
{
    <code>;
}
else;
{
    <code>;
}

One line:

if (<variable> == <value>); {<code>;}

C

if (<variable> == <value>)
{
    <code>
}
elif (<variable> == <value>)
{
    <code>
}
else
{
    <code>
}

Python

Method one:

if <variable> == <value>:
    <code>
elif <variable> == <value>:
    <code>
else:
    <code>

Method two:

if <variable> == <value>: <code>
elif <variable> == <value>: <code>
else: <code>

Fortran

if (<variable> == <value>) then
    <code>
else if (<variable> == <value>) then
    <code>
else
    <code>
end if

Windows Batch

if [Not] <variable>==<value> (
    <code>
) else (
    <code>
)

One line:

if <variable>==<value> (<code>) else (<code>)

PowerShell

(! is used for Not)

if ([!] <statement>) {
    <code>
} elseif (<statement>) {
    <code>
} else {
    <code>
}

One line:

if (<statement>) {<code>} elseif (<statement>) {<code>} else {<code>}

Bash

(! is used for Not)

if [ [!] "<variable>" = "<value>" ]
  then
    <code>
elif [ "<variable>" = "<value>" ]
  then
    <code>
else
    <code>
fi

One line:

if ["<variable>"="<value>"]; then; <code>; elif ["<variable>"="<value>"]; then; <code>; else; <code>; fi

Lua

(~ is used for Not instead of the first =)

if <variable> [~|=]= <value> then
  <code>
else
  <code>
end

One line:

if <variable> == <value> then <code> end

FreeBASIC

if <variable> = <value> then
    <code>
elseif <variable> = <value> then
    <code>
else
    <code>
end if

Jekyll

{% if <variable> == <value> %}
    <code>
{% else %}
    <code>
{% endif %}

An unless if:

{% unless <expression> %}
    <code>
{% endunless %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment