Ruby Curly Braces?

I apologize if this is a dumb question. I’m trying to learn Ruby and Appium at the same time here. I’ve been reading the documentation and I’m confused on some syntax. The method here:

exists { text("my text") } ?

This returns a boolean and tells whether or not an element exists, which is quite useful. But what is the purpose of the curly braces? If it’s a method call, wouldn’t it just use parenthesis? Also, why is the question mark at the end?

It’s a code block, often referred to as just a ‘block’. This will explain it:

1 Like

Awesome, that cleared it up. Thanks!

Is the question mark just the beginning of a ternary operator or does it mean something else?

In this case I think it just tests that the block returns true.

1 Like