fasterCSV meaning of a line

What is the meaning of line?:

if !in_quotes || in_quotes[@parsers[:stray_quote]]

at line approx 1643 in faster_csv.rb

!in_quotes => if in_quotes is nil or false

in_quotes[…] => calls the #[] method on in_quotes with the given
argument

So this is effectively saying:

if in_quotes[@parsers[:stray_quote]]

but with a get-out clause which avoids the line bombing out if in_quotes
is nil.

in_quotes[…] => calls the #[] method on in_quotes with the given
argument

Is this functional programming?

If so or even if I am wrong, kindly help me with some pointer to
understand it betetr and have better grip on RUBY!

in_quotes[…] => calls the #[] method on in_quotes with the given

What is #[] method?

Hi,

ajay paswan wrote in post #1071826:

in_quotes[…] => calls the #[] method on in_quotes with the given
argument

Is this functional programming?

What do you mean by “functional programming”?

As to the usual meaning of the word: no.

ajay paswan wrote in post #1071904:

in_quotes[…] => calls the #[] method on in_quotes with the given

What is #[] method?

It is the method that you define by

def

end

and call by

your_object[…]

It’s the “indexing method” known from arrays:

arr = [1, 2, 3]
puts arr[0] # <-- this calls the “[]” method of the Array class

Jan E. wrote in post #1071905:

arr = [1, 2, 3]
puts arr[0] # <-- this calls the “[]” method of the Array class

Exactly.

In this case, because ruby is a dynamic language, what precisely it does
depends on what objects @parsers and in_quotes represent at runtime. So
you need to work back through the code to find where they are set.

At a guess, I would say @parsers is quite likely to be a Hash. If that’s
true, @parsers[:stray_quote] will get you the Hash value whose key is
the symbol :stray_quote.

parsers = {:fluffy=>123, :wombat=>456}
=> {:fluffy=>123, :wombat=>456}

parsers[:fluffy]
=> 123

parsers[:wombat]
=> 456

But this isn’t necessarily so; @parsers could be any object which
implements a [] method.

saytwice = lambda { |x| x + x }
=> #Proc:0x0000000101c2b6c0@:9(irb)

saytwice[“hello”]
=> “hellohello”