pwnd_sfw has quit [Read error: Connection reset by peer]
pwnd_sfw has joined #ruby
lucf117 has joined #ruby
lucf117 has quit [Ping timeout: 272 seconds]
simao has quit [Quit: WeeChat 3.1]
Rounin has joined #ruby
neshpion has quit [Quit: neshpion]
vaillancourtmax has quit [Ping timeout: 240 seconds]
ua_ has quit [Excess Flood]
ua_ has joined #ruby
ur5us has quit [Ping timeout: 240 seconds]
gr33n7007h has quit [Quit: WeeChat 3.2]
_ht has joined #ruby
teclator has joined #ruby
lad has quit [Ping timeout: 240 seconds]
gggp_ is now known as gggp
yxhuvud has quit [Read error: Connection reset by peer]
yxhuvud has joined #ruby
lzap7 has joined #ruby
lzap7 is now known as lzap
gggp has quit [Read error: Connection reset by peer]
gggp has joined #ruby
drincruz_ has joined #ruby
Edward123 is now known as EdwardIII
drincruz_ has quit [Ping timeout: 265 seconds]
lunarkitty has quit [Quit: Connection closed for inactivity]
gggp has quit [Read error: Connection reset by peer]
fossdd has quit [Ping timeout: 240 seconds]
lunarkitty has joined #ruby
fossdd has joined #ruby
mrkz_c has quit [Quit: Connection closed for inactivity]
fossdd has quit [Ping timeout: 240 seconds]
fossdd has joined #ruby
gggp has joined #ruby
gggp has quit [Read error: Connection reset by peer]
fossdd has quit [Remote host closed the connection]
gggp has joined #ruby
gggp_ has joined #ruby
gggp has quit [Ping timeout: 265 seconds]
ur5us has joined #ruby
gggp_ has quit [Read error: Connection reset by peer]
ur5us has quit [Ping timeout: 272 seconds]
gggp has joined #ruby
gggp_ has joined #ruby
gggp has quit [Ping timeout: 258 seconds]
Oxfuxxx_ has joined #ruby
Oxfuxxx has quit [Ping timeout: 265 seconds]
drincruz_ has joined #ruby
gggp__ has joined #ruby
gggp_ has quit [Ping timeout: 272 seconds]
gggp has joined #ruby
gggp__ has quit [Ping timeout: 256 seconds]
gcd has joined #ruby
drincruz_ has quit [Ping timeout: 240 seconds]
Oxfuxxx has joined #ruby
Oxfuxxx has quit [Read error: Connection reset by peer]
lunarkitty has quit [Quit: Connection closed for inactivity]
Oxfuxxx_ has quit [Ping timeout: 258 seconds]
gggp_ has joined #ruby
Oxfuxxx has joined #ruby
TomyWork has joined #ruby
gggp has quit [Ping timeout: 272 seconds]
Oxfuxxx_ has joined #ruby
goepsilongo has quit [Quit: Konversation terminated!]
Oxfuxxx has quit [Ping timeout: 252 seconds]
drincruz_ has joined #ruby
Oxfuxxx_ has quit [Read error: Connection reset by peer]
Oxfuxxx has joined #ruby
Oxfuxxx_ has joined #ruby
Oxfuxxx has quit [Ping timeout: 272 seconds]
Oxfuxxx_ has quit [Read error: Connection reset by peer]
Oxfuxxx has joined #ruby
Oxfuxxx_ has joined #ruby
Oxfuxxx has quit [Ping timeout: 258 seconds]
Melantha has joined #ruby
gggp_ has quit [Read error: Connection reset by peer]
gggp has joined #ruby
wei1 has joined #ruby
qk1z has quit [Ping timeout: 265 seconds]
gggp_ has joined #ruby
gggp has quit [Ping timeout: 258 seconds]
gggp_ has quit [Read error: Connection reset by peer]
gggp_ has joined #ruby
crankharder has joined #ruby
Oxfuxxx_ has quit [Ping timeout: 272 seconds]
Oxfuxxx has joined #ruby
horribleprogram has joined #ruby
<horribleprogram>
guys
<horribleprogram>
new to Ruby
<horribleprogram>
require "foo"
<horribleprogram>
can someone take me through the sort of PATH this searches
<horribleprogram>
also is there different sorts of "strings" such as "./foo" "/foo" etc?
<horribleprogram>
also what is require "zlib" for example
<horribleprogram>
is zlib a file that gets parsed and turned into a "module" object or some shit and all the top-level declarations are now part of the global scope of the file using that module
<horribleprogram>
im familiar with both Python and the many JS import systems
<horribleprogram>
so if y'all can explain how ruby imports things or link to a good resource I'd love that
<horribleprogram>
s/how ruby imports things/how ruby imports things analogous to either python or JS/
<leah2>
horribleprogram: look at $LOAD_PATH
<leah2>
it tries that in order, and looks for foo.rb or foo.so (or foo.dll on windows maybe)
<leah2>
as . is usually not in $LOAD_PATH, require "./foo" will do something else yes
<leah2>
there is also require_relative
<leah2>
the other thing to know is $LOADED_FEATURES, where require stores what it loaded
<leah2>
and wont load it again if you require again
<leah2>
and there is no module system else, it just loads the file in global scope
<horribleprogram>
leah2: like an #include ?
<leah2>
pretty much
<leah2>
except for local variables
Oxfuxxx has quit [Read error: Connection reset by peer]
<horribleprogram>
ahh kk
<leah2>
but namespacing is done via module/class statements
<horribleprogram>
yeah
<leah2>
it does not need to correlate with file names (but is good to do ofc)
<horribleprogram>
I notice that the stdlib has a good convention
<horribleprogram>
"foo.rb" has a Foo class or w/e that namespaces all the top-level stuff
<leah2>
not always, e.g. require 'strscan' adds StringScanner
<horribleprogram>
ahh
<leah2>
but that's legacy i guess :)
<horribleprogram>
well I guess u can provide some sort of wrapper
<leah2>
(also it's a gem now)
<horribleprogram>
idk if require is a statement or expression... but u probably don't even need to use it
<horribleprogram>
what's a GEM?
<horribleprogram>
gem
<leah2>
require is just a method
<leah2>
gem is the packaging system of ruby
<leah2>
like python pip or so
<horribleprogram>
u don't use function call invocations tho
<horribleprogram>
ahh kk
<leah2>
you dont need () in ruby
<leah2>
puts "foo" is also just a method call
<horribleprogram>
AHHH
<leah2>
:)
<horribleprogram>
is there any difference
<horribleprogram>
in terms of precedence
<leah2>
yes
<horribleprogram>
puts "foo".blah or puts("foo").blah
<horribleprogram>
kk
<leah2>
exactly
<leah2>
the former calls .blah on "foo"
<horribleprogram>
makes sense
<leah2>
also with blocks it's different
<leah2>
foo a, b, c do .. end
<leah2>
is the same as foo(a,b,c) { .. }
<horribleprogram>
kk last noob question
<horribleprogram>
this absolute value syntax
<horribleprogram>
|x|
<leah2>
block arguments, yes
<horribleprogram>
okay what's this
Oxfuxxx has joined #ruby
<leah2>
lambda { |x| x*2 } in python would be lambda x: x*2
<leah2>
so if you call it, it binds the value to the block argument
<leah2>
lambda { |x| x*2 }.call(3) #=> 6
<horribleprogram>
neat
<leah2>
and you can pass one block to each method invocation
<leah2>
so lambda is not a keyword either, but a method :D
<leah2>
3.times { |i| puts i }
<leah2>
syntax looks a bit weird at first, but it's a cool feature imo
<horribleprogram>
I see what it does I think
<horribleprogram>
assuming 3.times does what I think it does
<leah2>
it calls the block three times
<leah2>
and passes the number of the run
<leah2>
["foo", "bar", "baz"].each { |x| puts x }
<leah2>
that's how you do iteration in ruby
<horribleprogram>
yeah like JS
<leah2>
right
<horribleprogram>
ur passing lambdas to methods
<leah2>
except js always passes index
<leah2>
in ruby you can use .each_with_index { |x,i| ... }