In the beginning of the year, we discussed Reporter Blocks and their use cases. Today lets’s talk about a special type of Reporter Blocks, known as Predicate blocks. Predicate blocks are of trapezoidal shape and must return true or false. Some of the examples of predicate blocks in Operators palette are:
and in Sensing palette are:
Why are predicate blocks special?
Predicate blocks are considered special cases of reporter blocks, since they can be used in conditional statements and eventually defining the flow of the code.
Playing with Predicate Blocks
Now let’s test some simple predicate blocks.
Drag less than (<) predicate block to the scripting area, and type in 2 random numbers. For this example, I typed in 2 and 5 as an input. Now, click on it and you will see the result of the equation. Since I typed in 2<5 for this example, it shows the result as true.
Now let’s use this predicate block as an input to the if-else block
Type the same code in SNAP! and see the results yourself :).
I hope this post helped you understand predicate blocks. Please feel free to leave a comment below if you have any questions/feedback.
I am extremely impressed with your writing skills and also with the layout on your weblog. Is this a paid theme or did you modify it yourself? Anyway keep up the nice quality writing, it is rare to see a nice blog like this one today..
I loved your post, my name is ronald spinabella and I’m going to share it with my followers on instagram.
I loved your blog post, it was great!
Anytime I research a topic I have no idea what i will discover. I am so very happy to have discovered your complete blogging as it properly covers the questions I have under consideration and also the unmentioned questions which i might have checked for in the future.
Heya i am for the first time here. I came across this board and I to find It truly useful & it helped me out a lot. I’m hoping to provide something again and help others such as you helped me.
Hello. impressive job. I did not anticipate this. This is a impressive story. Thanks!