# RVAL2CBOOL lax type check

**URL:** <https://www.ruby-forum.com/t/rval2cbool-lax-type-check/109355>\
**Category:** Ruby-Gnome 2\
**Created:** [July 13, 2007, 6:25pm UTC](https://www.ruby-forum.com/t/rval2cbool-lax-type-check/109355 "2007-07-13T18:25:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![blueprint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/cc9497/32.png) [@blueprint](https://www.ruby-forum.com/u/blueprint)\
**Post date:** [July 13, 2007, 6:25pm UTC](https://www.ruby-forum.com/t/rval2cbool-lax-type-check/109355/1 "2007-07-13T18:25:03Z")

</div>

So we now use RVAL2CBOOL for rg2 library calls awaiting a gboolean  
parameter. Though, RVAL2CBOOL is RTEST and RTEST is kinda lax: it  
accepts barely any ruby value. So basically you can pass nil, a  
string, or a widget and these will all be false (except nil of  
course).

What if we added a check in the RVAL2CBOOL macro, to rb\_warn on  
anything else than Qtrue and Qfalse?

–  
Guillaume C. - [http://zarb.org/~gc/](http://zarb.org/~gc/)

* * *

This [SF.net](http://SF.net) email is sponsored by DB2 Express  
Download DB2 Express C - the FREE version of DB2 express and take  
control of your XML. No limits. Just data. Click to get it now.  
[http://sourceforge.net/powerbar/db2/](http://sourceforge.net/powerbar/db2/)

---

<div class="post-metadata">

**Author:** ![blueprint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/cc9497/32.png) [@blueprint](https://www.ruby-forum.com/u/blueprint)\
**Post date:** [July 13, 2007, 6:26pm UTC](https://www.ruby-forum.com/t/rval2cbool-lax-type-check/109355/2 "2007-07-13T18:26:03Z")

</div>

> string, or a widget and these will all be false (except nil of

… will all be _true_

(week-end is here for taking some rest)

–  
Guillaume C. - [Guillaume Cottenceau](http://zarb.org/~gc/)

* * *

This [SF.net](http://SF.net) email is sponsored by DB2 Express  
Download DB2 Express C - the FREE version of DB2 express and take  
control of your XML. No limits. Just data. Click to get it now.  
[http://sourceforge.net/powerbar/db2/](http://sourceforge.net/powerbar/db2/)

---

<div class="post-metadata">

**Author:** ![blueprint](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/cc9497/32.png) [@blueprint](https://www.ruby-forum.com/u/blueprint)\
**Post date:** [July 13, 2007, 7:19pm UTC](https://www.ruby-forum.com/t/rval2cbool-lax-type-check/109355/3 "2007-07-13T19:19:12Z")

</div>

Hi,

On Fri, 13 Jul 2007 18:23:49 +0200  
“Guillaume C.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> So we now use RVAL2CBOOL for rg2 library calls awaiting a gboolean  
> parameter. Though, RVAL2CBOOL is RTEST and RTEST is kinda lax: it  
> accepts barely any ruby value. So basically you can pass nil, a  
> string, or a widget and these will all be false (except nil of  
> course).
> 
> What if we added a check in the RVAL2CBOOL macro, to rb\_warn on  
> anything else than Qtrue and Qfalse?

No,no. The values except false/nil becomes true in Ruby.  
It’s a correct behaviour. So we don’t need to warn such things.

–  
.:% Masao M.[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

* * *

This [SF.net](http://SF.net) email is sponsored by DB2 Express  
Download DB2 Express C - the FREE version of DB2 express and take  
control of your XML. No limits. Just data. Click to get it now.  
[http://sourceforge.net/powerbar/db2/](http://sourceforge.net/powerbar/db2/)
