If[]

✅ Works in Interactive Notebook

Category: Logic.

Run code if a statement is true.

Syntax

If[statement]
    ...

Arguments

Examples

The following example loads an image, reads the text in the image, and shows the image if it contains "tea".

Load["./photo.jpg"]
GetText[]
If[Read[] == "tea"]
    Show[]

In this example, Read[] == "tea" is the statement to evaluate. If this statement returns True, the indented statements are run. Otherwise, the indented statements are not run.

See Also

Made with ❤️ by capjamesg