📚 [Tutorial] Checking variable type

by KeterDev

Version 1 (March 1, 2019)

Download (84 downloads)

Difficulty: easy (simple functions, 2 block/flow beginning)
Determine automate variable type with JSON encoding.

This is just a tutorial flow. I've used Variable Set's just to make explanation easier. More blocks = easier to understand how flow works.

So, since automate may be considered a scripting language (even though it's not really language), which is using dynamic typing, there has to be a way to check variable's type... Well, here's my solution.

Explanations (they are analogical for the other flow beginnings)
1. You set your variable in "Variable Set" (Block #3)
2. You cast json encoded value to string, then match it against integer-specific regular expression (string can only contain digits)
3. Result of regular expression matching is cast to boolean with double negotiation, so if variable type is integer, it returns 1, 0 otherwise.

4.5 average rating from 8 reviews

5 stars
4 stars
3 stars
2 stars
1 star

Reviews and ratings can be submitted in the app.