Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby - source code - coding style

Looking through the Ruby code it has the following for proc_arity:

static VALUE
proc_arity(VALUE self)
{
    int arity = rb_proc_arity(self);
    return INT2FIX(arity);
}

More of a C coding style question really but why is static VALUE on a separate line instead of something like this:

static VALUE proc_arity(VALUE self)
like image 796
Snowcrash Avatar asked Jun 13 '13 22:06

Snowcrash


People also ask

What is RuboCop in Ruby?

RuboCop is a Ruby static code analyzer (a.k.a. linter ) and code formatter. Out of the box it will enforce many of the guidelines outlined in the community Ruby Style Guide. Apart from reporting the problems discovered in your code, RuboCop can also automatically fix many of them for you.

What is identifiers in Ruby?

Identifiers are names of variables, constants, and methods. Ruby identifiers are case sensitive. It means Ram and RAM are two different identifiers in Ruby. Ruby identifier names may consist of alphanumeric characters and the underscore character ( _ ).


1 Answers

It comes from the UNIX world, because it helps to easily grep the definition of a function:

$ grep -n '^proc_arity' *.c

or using vim:

/^proc_arity
like image 188
ouah Avatar answered Oct 01 '22 00:10

ouah