Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ruby/ruby.h"
- VALUE even_m(VALUE self, VALUE num_val)
- {
- int num = NUM2INT(num_val);
- if(num % 2 == 0){
- return Qtrue;
- }else{
- return Qfalse;
- }
- }
- void Init_even(void){
- VALUE cEven = rb_define_class("Even", rb_cObject);
- rb_define_method(cEven, "even?", even_m, 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement