nertzy_ has quit [Read error: Connection reset by peer]
deviantfero has quit [Ping timeout: 240 seconds]
nertzy has joined #ruby
ur5us__ has joined #ruby
FastJack has quit [Ping timeout: 240 seconds]
vondruch_ has joined #ruby
vondruch has quit [Ping timeout: 240 seconds]
vondruch_ is now known as vondruch
jenrzzz has quit [Ping timeout: 260 seconds]
SpacePlod has quit [Ping timeout: 252 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jenrzzz has joined #ruby
RougeR has joined #ruby
Default__ has joined #ruby
SpacePlod has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
Default__ has quit [Client Quit]
ur5us__ has quit [Ping timeout: 245 seconds]
jenrzzz has joined #ruby
cuerbot has quit [Read error: Connection reset by peer]
elcuervo has joined #ruby
jamees has quit [Quit: Connection closed]
Glumetu has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
<Glumetu>
Hello i would like to ask for a link of documentation about this situation ... i calculate the value for a variable inside a loop and i can't seem to be able to use it or print it outside the loop.
ur5us has joined #ruby
jenrzzz has joined #ruby
<_aeris_>
Glumetu > define your variable outside the loop initially
MalkbabY has quit [Remote host closed the connection]
MalkbabY has joined #ruby
<_aeris_>
loop use a block, and block uses a different scope for variable, so if not defined outside the block first, the variable is only available from the block scop
jenrzzz has quit [Ping timeout: 240 seconds]
<_aeris_>
so 10.times { a = 1 } p(a) doesn't work, a not defined after the block, but a=nil; 10.times { a = 1 } p(a) works
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
TK__ has quit [Ping timeout: 258 seconds]
<Glumetu>
Thank you so much _aeris_
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
jenrzzz has joined #ruby
henninb has joined #ruby
FastJack has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
jenrzzz has joined #ruby
_nick_ has joined #ruby
Bounga has joined #ruby
ur5us has quit [Ping timeout: 252 seconds]
feriman has quit [Quit: WeeChat 3.1]
jenrzzz has quit [Ping timeout: 240 seconds]
Bounga has quit [Ping timeout: 246 seconds]
TCZ has joined #ruby
jetchisel has quit [Ping timeout: 265 seconds]
c355e3b has quit []
jenrzzz has joined #ruby
_nick_ has quit [Ping timeout: 240 seconds]
va5c0 has joined #ruby
jetchisel has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
jenrzzz has joined #ruby
m27frogy has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
jenrzzz has joined #ruby
Default__ has joined #ruby
jenrzzz has quit [Ping timeout: 240 seconds]
<Default__>
I'm trying to create a updateable content but having problems with the syntax for the variable. I'm a beginner. Is anyone interested in helping quick?
<jhass>
it's best to just describe your problem in detail rather than looking for an expert upfront :)
tens0r has joined #ruby
tens0r has left #ruby [#ruby]
<Default__>
ok so I'm making the meta description updateable. I've generated an SeoContentModel. Then I've created the table and meta title,meta description in a migration file. I've also added another method to add dummy content there. I have a seo_content model with just the class in. In the home controller I have "@meta_description = CreateSeoContents.seo_contents.meta_description" which comes back with a name error
tensor-dev has joined #ruby
tensor-dev has quit [Read error: Connection reset by peer]
<alestane>
Hello; I'm dealing with a situation where a variable might contain a hash with existing pairs, or might contain Nil. If there's a hash there, I want to add a new pair to it; if there isn't, I want to set the variable to hold a new hash containing only that pair. I can certainly do this fairly clumsily, but is there a standard clean idiom for it? Google has so far yielded only tutorials about basic hash use.
jenrzzz has joined #ruby
<leftylink>
interesting. I'd use Hash#merge, and || for the case when it's nil.
vondruch has quit [Client Quit]
<jhass>
I'd look into any way there's to change whatever place the nil's coming from to return an empty hash instead
vondruch has joined #ruby
arahael has left #ruby ["WeeChat 2.7.1"]
ChmEarl has joined #ruby
<jhass>
but if that's impossible, (foo ||= {}).merge!(key: :value) for modifying or foo = (foo || {}).merge(key: :value) ain't too bad
vondruch has quit [Client Quit]
vondruch has joined #ruby
<alestane>
The ||= operator looks like the key I was missing, I'lll test a couple approaches. Unfortunately the target location is an index in an array, which sounds like it doesn't do default values well.
jenrzzz has quit [Ping timeout: 240 seconds]
<jhass>
.fetch(n, {})
<alestane>
Will that add the new hash to the array as well?
<jhass>
no
<leftylink>
it's not clear to me why the array poses a problem - would it not mean that foo in the above examples just becomes a[i] ? all examples above would still work there
<leftylink>
maybe the array is elsewhere and thus I've just misunderstood
<alestane>
(arr[i] ||= {})[k] = v appears to work fine.
<jhass>
a non-continous array might want to actually be a hash however and then you could do Hash.new {|h, k| h[k] ||= {} }
<alestane>
The biggest reason I want it to be an array is to order things. They will be mostly contiguous.
<alestane>
But I have to be ready for occasional bits of broken user entry.
MalkbabY has quit [Remote host closed the connection]
<alestane>
Validation would help, but I've also learned to be leery of the assumption that all user data in the store is clean and valid.
<alestane>
I think this is what I was looking for, very much appreciated.
MalkbabY has joined #ruby
<jhass>
gladly :)
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
vondruch has quit [Client Quit]
jenrzzz has joined #ruby
vondruch has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
gr33n7007h has joined #ruby
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
Nowaker has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
Rudd0 has quit [Ping timeout: 268 seconds]
neozor has quit [Remote host closed the connection]
howdoi has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
jamees has joined #ruby
va5c0 has quit [Ping timeout: 265 seconds]
va5c0 has joined #ruby
tomaw has quit [Quit: Quitting]
gr33n7001 has joined #ruby
centrx has joined #ruby
jenrzzz has joined #ruby
gr33n7007h has quit [Ping timeout: 260 seconds]
jamees has quit [Quit: Connection closed]
jenrzzz has quit [Ping timeout: 246 seconds]
centrx_ has joined #ruby
jenrzzz has joined #ruby
centrx has quit [Ping timeout: 258 seconds]
mangold has joined #ruby
robotbee has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
cd has quit [Quit: cd]
cd has joined #ruby
cd has quit [Client Quit]
robotbee has quit [Ping timeout: 265 seconds]
Glumetu has left #ruby [#ruby]
cthu| has joined #ruby
jenrzzz has joined #ruby
alestane has quit [Quit: alestane]
jenrzzz has quit [Ping timeout: 260 seconds]
<rapha>
see y'all on the other side, it was a good time here!
rapha has left #ruby ["switching to libera"]
Bounga has quit [Ping timeout: 240 seconds]
pinkpandabot is now known as pandabot
gr33n7001 has quit [Quit: WeeChat 3.1]
Nowaker has joined #ruby
Azure has quit [Ping timeout: 240 seconds]
robotbee has joined #ruby
jenrzzz has joined #ruby
cd has joined #ruby
mangold has quit [Ping timeout: 240 seconds]
cd has quit [Client Quit]
centrx_ has quit [Remote host closed the connection]
jenrzzz has quit [Ping timeout: 260 seconds]
<nakilon>
he's still connected to Freenode, just idle, so what's the point
Azure has joined #ruby
feriman has joined #ruby
lightstalker has quit [Read error: Connection reset by peer]
centrx has joined #ruby
centrx has quit [Ping timeout: 258 seconds]
jenrzzz has joined #ruby
jenrzzz has quit [Ping timeout: 246 seconds]
s2013 has joined #ruby
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
mangold has joined #ruby
jenrzzz has joined #ruby
centrx has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
centrx has quit [Ping timeout: 258 seconds]
eddof13 has joined #ruby
Rudd0 has joined #ruby
jenrzzz has joined #ruby
dviola has left #ruby ["WeeChat 3.1"]
jenrzzz has quit [Ping timeout: 260 seconds]
mangold has quit [Ping timeout: 260 seconds]
LiteWait has joined #ruby
mangold has joined #ruby
jenrzzz has joined #ruby
centrx_ has joined #ruby
centrx_ has quit [Ping timeout: 258 seconds]
miah has quit [Quit: DevOps? DerpOps maybe!]
cd has joined #ruby
cd has quit [Client Quit]
cd has joined #ruby
cd has quit [Client Quit]
cd has joined #ruby
_whitelogger has joined #ruby
cd has quit [Client Quit]
cd has joined #ruby
cd has quit [Client Quit]
sysadmin has joined #ruby
LiteWait has quit [Quit: Connection closed]
cd has joined #ruby
_whitelogger has joined #ruby
duderonomy has joined #ruby
jla has joined #ruby
centrx has joined #ruby
centrx has quit [Ping timeout: 258 seconds]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
centrx has joined #ruby
mangold_ has joined #ruby
mangold has quit [Ping timeout: 260 seconds]
centrx has quit [Ping timeout: 258 seconds]
teclator has quit [Ping timeout: 245 seconds]
clinth has left #ruby [#ruby]
<fowl>
is WEBrick::HTTPUtil.quote supposed to remove "s inside? it replaces them with \
MalkbabY has quit [Remote host closed the connection]
MalkbabY has joined #ruby
lightstalker has joined #ruby
dviola has joined #ruby
<sysadmin>
Remember Bitcoin in 2008??? Pi is a new digital currency developed by Stanford PhDs, To claim your piece of pi goto https://minepi.com and use "ilkde" as your invitation code. Get your piece of the pi now !
<jhass>
fowl: yeah seems weird, the implementation seems to want to use a backreference but doesn't even define a capture group. Anyways, I doubt it's considered public API and even if it were I wouldn't use it in new code since webrick is dropped from the standard library in Ruby 3
sysadmin has quit [Ping timeout: 260 seconds]
teclator has joined #ruby
eris has joined #ruby
Na_Klar has joined #ruby
feriman has quit [Quit: WeeChat 3.1]
feriman has joined #ruby
eris has quit [Remote host closed the connection]
eris has joined #ruby
split-brain has quit [Remote host closed the connection]
<Qchmqs>
rubygems doesn't download all the internet, you're thinking of npm
<cek>
despite temple resolving to 0.8.2 just fine.
<adam12>
cek: Sometimes if Bundler can’t determine a certain way to resolve a dependency it will fetch a full index. Maybe that’s what you’re seeing? I dont’ remember the exact logic tho.
<cek>
yes it does: Need to query more than 500 gems. Downloading full index instead...
<cek>
is the Marshalled stuff what's called a 'full index'?
<cek>
I thought it was specs.4.8.gz
<cek>
why doesn't it fetch that file goddamit?
<adam12>
cek: This is your mirror?
<cek>
mine!
<cek>
cek> i[m mirroring wiht `gemirro` and don't want to pull all internet.
<cek>
it appears that was indeed coming from specs.4.8.gz being loaded and parsed and those lower gem versions extracted and looked up. All because gemirro just downloaded that file from rubygems instead of generating from gems it fetched.
<cek>
thanks guys!
vondruch_ has joined #ruby
felipec has joined #ruby
vondruch_ has quit [Client Quit]
vondruch has quit [Read error: Connection reset by peer]
<jhass>
this is called a class variable and there's very very few legit usecases for them. Use a constant if you never reassign it or a class/module level instance variable if you do
cliluw has quit [Ping timeout: 265 seconds]
<felipec>
jhass: I did not ask how else would you do it, I asked if that code makes sense
GodFather has joined #ruby
vondruch has quit [Read error: Connection reset by peer]
<felipec>
A constant will leak to the user's of this library: they could do Test::ROOT_DIR
<havenwood>
felipec: No, class variables never make sense.
<havenwood>
felipec: They are broken by design and only remain in the language for backwards compatibility.
<havenwood>
felipec: Do *not* create class variables. Matz recommends avoiding class variables.
<felipec>
I'm still waiting for anybody to explain what is wrong
<leftylink>
moving goalposts detected
<pyra>
I honestly don't see why it's wrong to use class vars as constants. **provided you never change them and you never try to reassign them in children or parents**
cthu| has quit [Ping timeout: 265 seconds]
<felipec>
pyra: I won't
<jhass>
because reassigning a constant ruby will warn you and then it'll still behave as you expect. With a class var it likely won't behave as you expect
<havenwood>
pyra: There are better options. You *can* do it but Matz says "the use of class variables is not recommended (like global variables)..."
<felipec>
jhass: I won't reassign that constant
<jhass>
but maybe somebody else will
<havenwood>
felipec: Just doing use them. It's bad form. The creator of the language implores you.
<havenwood>
don't use*
<pyra>
havenwood: true
<felipec>
In fact, the real code is to fix rubygems by providing a useful operating_system.rb: https://dpaste.com/8CVMNMPCT
<havenwood>
There isn't a good reason to use them. There are several good reasons to avoid them.
<havenwood>
They're effectively deprecated by shunning.
<havenwood>
Use ones that exist, fine. Do not create more. That's the last thing we need.
<jhass>
anyhow, you wanted to hear why the community considers using them bad practice. Take the arguments or leave them, arguing opinion is pointless
<havenwood>
felipec: Use a constant.
<havenwood>
felipec: Freeze it for good measure. :P
<havenwood>
felipec: If you care about Gem::SYSTEM_DIR being exposed (why do you care?) use a private constant, which is for just that scenario.
feriman has quit [Ping timeout: 260 seconds]
<felipec>
havenwood: I didn't ask you what you would do
<felipec>
havenwood: I read that ticket, in there matz said he won't remove them for 3.0, and he doesn't want big changes because they would break backwards compatibility
<felipec>
havenwood: I'm not incurring in any of the problems listed in that ticket, therefore my use of the class variable is fine
<felipec>
If they didn't want people to use class variables, they would remove them
<havenwood>
felipec: Why are you telling me what you asked? I can read it. "Does it make sense to set a module class with code?" Answer is "no." It makes no sense. It's bad practice.
<jhass>
I don't get why you came here to ask if you're so convinced of being right
reyfi9e has joined #ruby
<havenwood>
felipec: I'd not be reopening Gem in the first place so it's a complete nonstarter what I'd do.
<havenwood>
felipec: Worry about you.
<havenwood>
felipec: And for the love of the gods, don't use class instance variables.
<havenwood>
Zoomed in to your question, a constant would be appropriate here since a class variable does not make sense.
<havenwood>
felipec: Go ahead and use a global variable if you'd like, but we've answered your question.
BTRE has left #ruby ["Leaving"]
<havenwood>
"If they didn't want people to use class variables, they would remove them" is not true.
<havenwood>
"They" don't want people using class variables but are unwilling to break code.
<pyra>
yeah, ruby is definitely very careful about backwards compatibility, it's just there as to not break things
<jhass>
it's something you'll find in most projects as old as ruby
<jhass>
you have to start considering what's best for your userbase in addition to what's the ideal design. That's not always aligned
gr33n7007h has joined #ruby
<felipec>
havenwood: I didn't ask if it was bad practice, you still haven't told me what is wrong with my code
Technodrome has joined #ruby
cliluw has joined #ruby
Azure has quit [Read error: Connection reset by peer]
Azure|dc has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<leftylink>
ok cool, I was hoping nobody was going to get baited by that
pyra has quit [Quit: Konversation terminated!]
pyra has joined #ruby
Technodrome has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
gearnode has quit [Ping timeout: 260 seconds]
hiroaki has quit [Ping timeout: 258 seconds]
mangold has joined #ruby
jenrzzz has joined #ruby
cliluw has quit [Ping timeout: 240 seconds]
cliluw has joined #ruby
hiroaki has joined #ruby
s2013 has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
mangold has quit [Ping timeout: 246 seconds]
felipec has quit [Quit: Leaving]
robotbee has quit [Remote host closed the connection]
robotbee has joined #ruby
cthulchu has joined #ruby
robotbee has quit [Remote host closed the connection]
robotbee has joined #ruby
niv has quit [Ping timeout: 260 seconds]
robotbee has quit [Ping timeout: 265 seconds]
niv has joined #ruby
va5c0 has quit [Ping timeout: 246 seconds]
jenrzzz has quit [Ping timeout: 265 seconds]
ur5us has joined #ruby
Qchmqs has quit [Remote host closed the connection]
cek has quit [Quit: Connection closed for inactivity]
jenrzzz has joined #ruby
sagax has quit [Ping timeout: 240 seconds]
reyfi9e has quit [Remote host closed the connection]
cuerbot has joined #ruby
reyfi9e has joined #ruby
reyfi9e has quit [Client Quit]
centrx has joined #ruby
elcuervo has quit [Ping timeout: 260 seconds]
t1054Gues has quit [Read error: Connection reset by peer]
centrx has quit [Ping timeout: 258 seconds]
centrx has joined #ruby
ruby[bot] has joined #ruby
t1054Gues has joined #ruby
MalkbabY has quit [Remote host closed the connection]
MalkbabY has joined #ruby
bkuhlmann has joined #ruby
bkuhlmann has left #ruby [#ruby]
TK__ has joined #ruby
johnny56_ has joined #ruby
johnny56 has quit [Ping timeout: 268 seconds]
johnny56 has joined #ruby
johnny56_ has quit [Ping timeout: 265 seconds]
lucasb has joined #ruby
vondruch has joined #ruby
teclator has quit [Ping timeout: 260 seconds]
cliluw has quit [Ping timeout: 246 seconds]
ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
work_ has joined #ruby
kluk has joined #ruby
postmodern has joined #ruby
bambanx has joined #ruby
pyra has quit [Ping timeout: 260 seconds]
work_ has quit []
robotbee has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
cliluw has joined #ruby
caronj has joined #ruby
cliluw has quit [Read error: Connection reset by peer]
deviantfero has quit [Ping timeout: 246 seconds]
robotbee has quit [Ping timeout: 265 seconds]
TCZ has joined #ruby
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
vondruch has quit [Ping timeout: 246 seconds]
bambanx has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]