pxt-calliope/docs/reference/out-of-bounds.md

44 lines
1.1 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# out of bounds
The behavior of functions whose parameter values are out of bounds.
Many of the BBC micro:bit functions have parameters. If a parameter is an unexpected value, the parameter is considered *out of bounds*.
2016-04-13 17:27:45 +02:00
For example, the [plot](/reference/led/plot) function has two parameters:
2016-03-26 00:47:20 +01:00
### syntax
```
export function plot(x: number, y: number)
```
### parameters
* x - the *x coordinate* or horizontal position (0, 1, 2, 3, 4)
* y - the *y coordinate* or vertical position (0, 1, 2, 3, 4)
### out of bounds
here's an example of code with an out of bounds parameter (the *x* and *y* parameters are outside the expected range of 0-4):
```
led.plot(9, -21)
```
### what happens?
Typically, when a parameter supplied to a function is out of bounds that function does nothing (as if the function never executed). So, in the above case, the LED screen will not change.
### return value
If you call the `point` function with an out of bounds parameter, the function returns `false`:
```
let on = led.point(5, -5)
```
### see also
2016-04-13 17:27:45 +02:00
For more information on the out-of-bounds behavior of a function, see the documentation for that [function](/js/contents).
2016-03-26 00:47:20 +01:00