<renkon>
hi, when creating a Proc with a block with 1 argument, result matches what i´m expecting. However, when I add a second argument to my block, it will always return false. any idea why?
cagomez_ has joined #ruby
<renkon>
this is the code: https://dpaste.de/3Lor . when adding another parameter to the block it will always return false
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mistergibson has joined #ruby
<havenwood>
renkon: Show the example that returns false?
<renkon>
like, just editing | original_list | to | original_list , something_else |
cagomez has quit [Ping timeout: 246 seconds]
<havenwood>
renkon: And you're also changing how the proc is being called?
<havenwood>
renkon: Are you then calling the proc with two arguments, since you added a second?
bmurt has joined #ruby
<havenwood>
renkon: When you say it returns false, do you mean returns falsey? I'm assuming it's just: nil
<havenwood>
renkon: Procs don't have strict arity like lambdas.
<havenwood>
#!> ArgumentError: wrong number of arguments (given 1, expected 2)
redlegion has quit [Quit: Fuck this, I'm out.]
<renkon>
isn't it like: Lambdas check the number of arguments, while procs do not
<renkon>
=> nil
<renkon>
[2] pry(main)> Proc.new { |a, b| b }.call 42
<havenwood>
renkon: There are a few differences between procs and lambdas, but one of this is indeed that lamdas balk when you call them with the wrong number of args and procs return `nil`.
<renkon>
indeed, but i'm not using a lambda. i'm using a proc
redlegion has joined #ruby
<havenwood>
renkon: Right, so if you add an arg, but don't call it with that arg, the arg will be `nil`.
<havenwood>
I said it badly.
<havenwood>
renkon: With a lambda, you'd get an argument error for the missing arg.
<havenwood>
renkon: With a proc, the missing arg is nil.
<havenwood>
(Which is falsey.)
<renkon>
indeed, second argument would be falsy, but then why would all the rest be false too?
<havenwood>
renkon: I'm just guessing you're adding a second proc arg, but not providing a second argument when calling it.
apeiros has joined #ruby
<havenwood>
renkon: I don't know why it'd change the return value of your proc altogether offhand. Have you been able to simplify it to a test case that shows off the issue or only just seeing it with your full code at this point?
<havenwood>
renkon: You're not actually using the second proc argument?
<havenwood>
renkon: Did you just add the second argument as a first step towards actually doing something, and that inexplicably caused things to fail?
dar123 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<havenwood>
renkon: Is it just destructuring your Array test? What's failing?
<renkon>
havenwood: yes. I'm planning to add a second argument to call basically, and when adding it to the block of list method, it automatically goes falsy for all cases
<havenwood>
renkon: Ahhh
<renkon>
and yes, it's making list(..).call(...) return false
<havenwood>
renkon: All of the tests?
<havenwood>
Or some?
<renkon>
all of the *list* tests.
<renkon>
some don't fail cause they expect it to be false
<havenwood>
>> proc { |a, b| b }.call [1, 2]
<havenwood>
renkon: ^ it's destructuring the Array arg
<renkon>
is there any mechanism so as not to break the array and treat it as a single parameter?
<havenwood>
renkon: It's one of the reasons I prefer lambdas.
patr0clus has quit [Ping timeout: 252 seconds]
<havenwood>
renkon: You can always call the proc with two arguments.
<havenwood>
renkon: Destructuring won't occur unless they're an argument mismatch.
<havenwood>
there's*
<renkon>
ok i will try to use a lambda then.
<havenwood>
renkon: A lambda would be the most explicit. But with a lambda you'll also have to call it with the actual number of arguments.
<renkon>
just to be sure, can i create a lambda of type "CombinableProc", which is like a "son" of Proc class?
patr0clus has joined #ruby
<renkon>
and, havenwood, could I use default values for lambdas? or that's unallowed? No problem if that's the case, because my CombinableProc would default a nil value for it otherwise.
orbyt_ has joined #ruby
<havenwood>
renkon: Yes, you can use default values with lambdas.
mikecmpbll has quit [Quit: inabit. zz.]
<havenwood>
renkon: And it'd prevent destructuring, so the Array would appear together as the first arg.
<havenwood>
renkon: A default value wouldn't work with a proc, since it'd still destructure.
<havenwood>
I mean default values work with procs generally, but not in this case where you're trying to prevent the destructuring.
<renkon>
last question: how would I be able to create a lambda of type CombinableProc (class that extends Proc)?
brandoncc has joined #ruby
gnufied has quit [Ping timeout: 244 seconds]
nowhere_man has quit [Ping timeout: 252 seconds]
<havenwood>
renkon: Interestingly a proc can't become a lambda, even if it's wrapped in a lambda.
<havenwood>
renkon: I don't know an OO way to inherit from a lambda proc offhand.
<renkon>
i found that I can use .extend at least with a module, that might do the trick
<havenwood>
>> lambda(&proc {}).lambda?
<havenwood>
#=> false
patr0clus has quit [Quit: WeeChat 2.1]
ramfjord has quit [Ping timeout: 240 seconds]
RougeR has quit [Ping timeout: 240 seconds]
johnny56 has quit [Ping timeout: 272 seconds]
krawchyk has joined #ruby
cthulchu_ has quit [Ping timeout: 252 seconds]
tristanp has quit [Remote host closed the connection]
akem has quit [Remote host closed the connection]
akem has joined #ruby
krawchyk has quit [Quit: krawchyk]
johnny56 has joined #ruby
apeiros has joined #ruby
<renkon>
thank you very much havenwood your help has been really useful
cagomez has joined #ruby
<havenwood>
renkon: you're welcome, any time
<renkon>
and now it's the last question regarding context, do you have any idea why does this happen: https://i.imgur.com/gDiA0ZF.png
apeiros has quit [Ping timeout: 240 seconds]
<renkon>
when I set J to some value, it shows that value, and if i force 'self.j' it would work as expected.
<renkon>
its like context is being mixed up
dar123 has joined #ruby
cagomez has quit [Ping timeout: 245 seconds]
LiftLeft has quit [Quit: Bye]
esrse has joined #ruby
LiftLeft has joined #ruby
<havenwood>
renkon: Either `j()` or `self.j` will explicitly call the method, otherwise the local variable has precedence.
<renkon>
OK, I'll write it down, thank you very much for everything.
<Tuor>
hi, I have installed the rvm package from the ppa: ppa.launchpad.net/rael-gc/rvm/ubuntu/.
graphene has quit [Remote host closed the connection]
<Knappe>
Hi, i've asked this question yesterday already but I can't scroll up far enough to see if I got an answer. Can anybody recommend a gem for chatting in IRC? I know there is cinch but I believe, since it's a bot framework, it could be overkill. All I need to do is connect to a IRC channel, sned a bunch of messages, evaluate the replys and disconnect again.
graphene has joined #ruby
<Tuor>
Now I have tried to install ruby with rvm, but I got a lot of erros like this: tar: binscripts: Cannot utime: Operation not permitted
RougeR has joined #ruby
isene has quit [Ping timeout: 240 seconds]
<Tuor>
What could be the problem?
<Knappe>
Seems like a permission issue. Try with sudo maybe
johnny56 has quit [Ping timeout: 272 seconds]
johnny56 has joined #ruby
DTZUZO has quit [Ping timeout: 244 seconds]
<Tuor>
Knappe: did the trick thx.: rvmsudo rvm get stable
<NL3limin4t0r>
Hey all, I'm trying to write a gem for Rails. (Don't worry this question is not specificly Rails related.) I want to prepend my module to an existing Rails module. This works fine, however the module is included before my gems prepends itself to that module. This in turn means that my prepended module is never called. What's the best way to resolve this? Should I just prepend the class that includes the module?
<NL3limin4t0r>
Or is there some way to make an inclution more like a reference (adopting futere changes to the module)?
<NL3limin4t0r>
Let me provide you with an easy example:
aufi has quit [Ping timeout: 252 seconds]
<NL3limin4t0r>
>> module A; def hello; puts 'hello from a';
<NL3limin4t0r>
^ oops, wasn't done yet
kotepillar_ has quit [Client Quit]
<NL3limin4t0r>
>> module A; def hello; puts 'hello from a'; end; end; class Foo; include A; end; module B; A.prepend self; def hello; super; puts 'hello from b'; end; end; Foo.new.hello
kotepillar_ has joined #ruby
* NL3limin4t0r
pokes ruby[bot]
<NL3limin4t0r>
#=> hello from a
dionysus69 has joined #ruby
mikecmpbll has joined #ruby
<NL3limin4t0r>
So this negates the prepended module, because A was included before B was prepended. If I were to reopen Foo and include A again the result would be: "hello from a\nhello from b"
<im0nde>
dionysus69: I would prefer not to install system-wide packages, but rvm-managed gems
<dionysus69>
just do gem install pkg-config
<im0nde>
dionysus69: I did that, it runs successfull
<dionysus69>
it won't be systemwide, it will be part of that specific ruby version assigned by rvm in that moment
aupadhye has quit [Ping timeout: 240 seconds]
<im0nde>
dionysus69: right, but I can'f find it even though it is installed
<dionysus69>
where is pkg-config should then return results, if not then maybe something specific is happening for that package
<dionysus69>
whereis rails returns for me for example: rails: /home/user/.rvm/gems/ruby-2.5.1/bin/rails
<dionysus69>
im0nde: ohh, maybe you are typing the name of the gem incorrectly, try with underscore
<im0nde>
dionysus69: no, it seems the executables are not fould. Do I have to modify the path?
<im0nde>
$PATH
<dionysus69>
no no, ok let me try install that gem
<im0nde>
ok
<im0nde>
In the end my goal is to install gruff, but it does not find pkg-config.
<im0nde>
running pkg-config in the shell gives "command not found"
<dionysus69>
for me it returns Must specify package names on the command line
<mememeIAMME>
Hi, I am trying to learn ruby for an upcoming interview. I am more used to C# so this is quite new. I haven't had problems until now, creating a program that removes vowels from a string if the vowel is at a odd number index. This is not only returning nil, but line 8 isn't running at all. https://dpaste.de/c9XT
<dionysus69>
where is returns pkg-config: /usr/bin/pkg-config /usr/lib/pkg-config.multiarch /usr/share/man/man1/pkg-config.1.gz, but from what I see it may conflict with system package, not sure
<im0nde>
what does "which pkg-config" return dionysus69 ?
<dionysus69>
- /usr/bin/pkg-config
<im0nde>
dionysus69: So you have installed it system-wide then
<dionysus69>
which is not a ruby gem, it has to conflict with OS package
pradhvan has joined #ruby
<dionysus69>
if it were installed by rvm it had to be in home dir .rvm
<dionysus69>
im0nde: I just deleted gem and still returns that path
<pradhvan>
Hey I am facing a problem " WARNING: You don't have /root/.gem/ruby/2.5.0/bin in your PATH," when I try to install jekyll
<pradhvan>
I tried adding PATH=$PATH:/home/pradhvan//.gem/ruby/2.5.0/bin export PATH to the bashrc but it does not work
<mememeIAMME>
I'm having a hard time getting help as well, don't feel bad.
<dionysus69>
no idea im0nde, I would check rvm dir for that gem manually, you cannot rely on env var $PATH
<mememeIAMME>
pradhvan I don't think many people are active at the moment.
<NL3limin4t0r>
mememeIAMME: Your if statement is incorrect. You currently have `if vowels.include? str[i] && i.odd?` This will first execute `str[i] && i.odd?` which has either `true` or `false` as result. Than checks if `vowels` include this result.
<NL3limin4t0r>
This is always false
<NL3limin4t0r>
The line should be `if vowels.include?(str[i]) && i.odd?`
<mememeIAMME>
NL3limin4t0r Ah I assumed the && would seperate them, I'm used to using () on everything now that I don't have to I am getting confused. Thanks!
<pradhvan>
mememeIAMME, I agree I guess. Can you look at it ?
<NL3limin4t0r>
mememeIAMME: Your while isn't very ruby-ish. You can replace it with `str.each_char.with_index do |c, i|`
<mememeIAMME>
NL3limin4t0r Interesting, I'm not quite understanding the meaning of all that but I'll stare at it for a few minutes and sure to get it haha
<pradhvan>
mememeIAMME, it's totally different
<mememeIAMME>
NL3limin4t0r So it loops through every character that has an index?
<mememeIAMME>
NL3limin4t0r Which would be... all of them
<pradhvan>
mememeIAMME, it's afternoon where I live
<mememeIAMME>
pradhvan 5 in the morning here lol
<pradhvan>
mememeIAMME, getting a taste of dev life :-P
<NL3limin4t0r>
The exports in my .bashrc do it in a single line and have quotes, I don't know if that makes a differance: `export PATH="$PATH:$HOME/.gem/ruby/2.5.0/bin"`
<pradhvan>
I am trying to fix a PR on github and need to see the changes I made I Need to run the server
<mememeIAMME>
pradhvan Definately. Trying to get in as much studying as I can. Need in the IT industry, have an interview with AppAcademy on Monday so I'm trying to learn a whole new language in a week 0.0
<mememeIAMME>
pradhvan The transition from C++ and C# to Ruby is quite odd.
<pradhvan>
mememeIAMME, haha I tried C++ for a month in college than I found Python never mover since :-P
<mememeIAMME>
pradhvan I've noticed a lot of similarities between python and ruby, too bad I only studied python for 2 days.
<pradhvan>
NL3limin4t0r, did not work :(
<pradhvan>
mememeIAMME, I have been doing it for 2 years now and hopefully will doing a lot more professionally
<mememeIAMME>
pradhvan Do you have a programming job?
<pradhvan>
mememeIAMME, will be graduating this year
<pradhvan>
so I guess will have one in future
<mememeIAMME>
pradhvan Awesome! I dropped out after 2 weeks :) It was too boring
<mememeIAMME>
pradhvan And that's why I am a Machinist
<pradhvan>
mememeIAMME, engineering ?
EnderMB has joined #ruby
<mememeIAMME>
pradhvan CS
<pradhvan>
mememeIAMME, I will be finishing 4 years now of CS hahaha
postmodern has quit [Remote host closed the connection]
<mememeIAMME>
pradhvan I have nothing but admiration for you. You must be a very patient human
<EnderMB>
Hey all, I've got a small Rubocop question. If I have a test that is throwing a RSpec/DescribeClass error on a line similar to "describe command('bash ...') ...", what would be the best way to resolve this to describe what is tested?
<pyrmont>
mememeIAMME: && has higher precedence and so your conditional won't work the way that you think it will. It's evaluating str[i] && i.odd? before it then calls include?. You need to put parentheses around str[i].
akem has quit [Ping timeout: 246 seconds]
<pradhvan>
mememeIAMME, :)
<mememeIAMME>
ppyrmont Yes, NLimin4t0r helped me out with that. This language is quite different than what I am used to. Thank you
<mememeIAMME>
pyrmont
<pyrmont>
No worries.
<pyrmont>
Was just skimming the history.
<mememeIAMME>
Anybody have experience with AppAcademy?
apeiros has quit [Remote host closed the connection]
apeiros has joined #ruby
roshanavand has joined #ruby
roshanavand has quit [Client Quit]
roshanavand has joined #ruby
roshanavand has quit [Client Quit]
ramfjord has quit [Ping timeout: 240 seconds]
bak1an has joined #ruby
sticaz has quit [Ping timeout: 252 seconds]
mikecmpbll has quit [Read error: Connection reset by peer]
mikecmpbll has joined #ruby
esrse has quit [Ping timeout: 272 seconds]
TvL2386 has joined #ruby
TvL2386 has quit [Quit: leaving]
TvL2386 has joined #ruby
roshanavand has joined #ruby
cpruitt has joined #ruby
kotepillar_ has joined #ruby
cpruitt has quit [Ping timeout: 252 seconds]
jottr has quit [Ping timeout: 244 seconds]
NL3limin4t0r has quit [Quit: WeeChat 1.9.1]
jottr has joined #ruby
NL3limin4t0r has joined #ruby
gnufied has quit [Ping timeout: 240 seconds]
jmcgnh has joined #ruby
akem__ has quit [Remote host closed the connection]
akem__ has joined #ruby
AJA4350 has joined #ruby
VladGh has quit [Remote host closed the connection]
aupadhye has quit [Ping timeout: 240 seconds]
VladGh has joined #ruby
EnderMB has quit [Ping timeout: 252 seconds]
nowhere_man has joined #ruby
CrazyEddy has joined #ruby
bak1an has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
CustosLimen has joined #ruby
<CustosLimen>
hi
thy0 has joined #ruby
<CustosLimen>
I used to take all of these dirs and put them in path "${HOME}/.gem/ruby/*/bin"
<CustosLimen>
but it seems gem does not install them there anymore
<CustosLimen>
or maybe my gemrc is wrong
snickers has joined #ruby
MoritaShinobu has joined #ruby
DTZUZO has joined #ruby
gnufied has joined #ruby
graphene has quit [Remote host closed the connection]
graphene has joined #ruby
gnufied has quit [Ping timeout: 252 seconds]
jottr has quit [Ping timeout: 240 seconds]
thy0 has quit [Quit: TTFN]
thy0 has joined #ruby
lyr has joined #ruby
RougeR has quit [Ping timeout: 252 seconds]
<lyr>
Hey. Quick question just for my curiosity, I'm not looking for a solution : I tried a hotfix on a gitlab (ruby + passenger), it didn't showed up when tested straight away. Is there a cache or compilation mecanism (like *.py => *.pyc file for python) in ruby ?
Knappe has quit [Quit: Leaving]
gnufied has joined #ruby
ramfjord has joined #ruby
RougeR has joined #ruby
<sonne>
lyr: i think passenger reloads the app based on triggers, such as touching config.ru. just picking from very old memories though.
ramfjord has quit [Ping timeout: 245 seconds]
gnufied has quit [Quit: Leaving]
jottr has joined #ruby
znz_jp has joined #ruby
mikecmpbll has quit [Read error: Connection reset by peer]
mikecmpbll has joined #ruby
knight33 has joined #ruby
snickers has quit [Ping timeout: 272 seconds]
roshanavand has quit [Ping timeout: 264 seconds]
kotepillar_ has quit [Quit: kotepillar_]
kotepillar_ has joined #ruby
kotepillar_ has quit [Client Quit]
zapata has quit [Read error: Connection reset by peer]
argoneus has quit [Quit: No Ping reply in 180 seconds.]
akem has joined #ruby
argoneus has joined #ruby
<z64>
this is really stumping me. rubocop is claiming that `Bar` in `module Foo::Bar` is missing a top level docs comment in a specific file (`Bar` spans multiple files). However, YARD renders just fine, and we do exactly this with other modules and it does not trigger a warning..
brandoncc has joined #ruby
argoneus has quit [Quit: No Ping reply in 180 seconds.]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
argoneus has joined #ruby
bomb has joined #ruby
maufart__ has quit [Ping timeout: 240 seconds]
bijan_ has joined #ruby
bmurt has joined #ruby
brandoncc has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tenderlove has joined #ruby
MoritaShinobu has quit [Ping timeout: 252 seconds]
thejs has quit [Remote host closed the connection]
thejs has joined #ruby
tenderlove has quit [Quit: Leaving...]
Emmanuel_Chanel has quit [Read error: Connection reset by peer]
Emmanuel_Chanel has joined #ruby
bijan_ has quit [Remote host closed the connection]
Tuor has quit [Ping timeout: 246 seconds]
conta1 has joined #ruby
MoritaShinobu has joined #ruby
fluxAeon has joined #ruby
rippa has joined #ruby
chouhoulis has quit [Remote host closed the connection]
chouhoulis has joined #ruby
dionysus70 has joined #ruby
cagomez has joined #ruby
dionysus70 has quit [Ping timeout: 240 seconds]
brandoncc has joined #ruby
lxsameer has quit [Ping timeout: 246 seconds]
lxsameer has joined #ruby
Synthead has joined #ruby
johnny56 has quit [Ping timeout: 272 seconds]
lxsameer has quit [Ping timeout: 246 seconds]
bak1an has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bijan_ has joined #ruby
lxsameer has joined #ruby
cthulchu has joined #ruby
lxsameer has quit [Ping timeout: 245 seconds]
lxsameer has joined #ruby
DTZUZO has quit [Ping timeout: 244 seconds]
<Synthead>
I added BUNDLE_BUILD__BYEBUG='--with-cflags=-Wno-error=attributes' to my environment, and "bundle config" confirms that it's in there. However, when I run "bundle", it still raises an error when compiling byebug: https://gist.github.com/synthead/59d70a500a17f2df751dc5891b44ed63
<Synthead>
If I cd to the byebug gem sources, edit Makefile and tack -Wno-error=attributes in there, "make" works
<Synthead>
What am I missing?
thejs has quit [Ping timeout: 272 seconds]
lxsameer has quit [Ping timeout: 244 seconds]
mikecmpbll has quit [Ping timeout: 245 seconds]
thejs has joined #ruby
[Butch] has joined #ruby
donofrio has quit [Remote host closed the connection]
bijan_ has quit [Remote host closed the connection]
bijan_ has joined #ruby
donofrio has joined #ruby
arand has joined #ruby
conta1 has quit [Quit: conta1]
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
bijan_ has quit [Remote host closed the connection]
lxsameer has joined #ruby
cagomez has quit [Remote host closed the connection]
cagomez has joined #ruby
hays_ has joined #ruby
<hays_>
how does !true work?
<hays_>
I was looking at :!.methods
cagomez has quit [Read error: Connection reset by peer]
<hays_>
and it seems like :!.send_public(true) won't do it
cagomez has joined #ruby
DTZUZO has joined #ruby
MoritaShinobu has quit [Quit: Leaving]
bijan_ has joined #ruby
johnny56 has joined #ruby
<hays_>
nvermind.
hays_ has quit [Read error: Connection reset by peer]
Synthead has quit [Remote host closed the connection]
lxsameer has quit [Ping timeout: 246 seconds]
<havenwood>
hays: You found unary operators?
<havenwood>
hays: class TrueClass; def !@; 42 end end; !true #=> 42
bijan_ has quit [Ping timeout: 252 seconds]
cagomez has quit [Remote host closed the connection]