Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. #include "ruby/ruby.h"
  2.  
  3. VALUE even_m(VALUE self, VALUE num_val)
  4. {
  5. int num = NUM2INT(num_val);
  6.  
  7. if(num % 2 == 0){
  8. return Qtrue;
  9. }else{
  10. return Qfalse;
  11. }
  12. }
  13.  
  14. void Init_even(void){
  15. VALUE cEven = rb_define_class("Even", rb_cObject);
  16. rb_define_method(cEven, "even?", even_m, 1);
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement