<mike11>
basically, I am doing a map, but if some condition is met on the current object, I want to pass it to the last added object instead of mapping it to something else...
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
mydog2 has quit [Ping timeout: 256 seconds]
sameerynho has joined #ruby
apparition has joined #ruby
quazimodo has joined #ruby
kapil___ has joined #ruby
<kapil___>
havenwood: thanks
Rootsudo has joined #ruby
quazimodo has quit [Ping timeout: 272 seconds]
BTRE has quit [Remote host closed the connection]
BTRE has joined #ruby
Freshnuts has quit [Quit: Leaving]
User458764 has joined #ruby
mojtaba has quit [Quit: Leaving.]
dhollin has joined #ruby
dhollin3 has quit [Ping timeout: 244 seconds]
clemens3 has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ferhaty has joined #ruby
Dbugger has joined #ruby
apparition has quit [Quit: Bye]
mike11 has quit [Quit: Leaving.]
alehander42_ has quit [Remote host closed the connection]
User458764 has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
gheegh has joined #ruby
User458764 has joined #ruby
howdoi has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
alex`` has quit [Quit: WeeChat 2.2]
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
mikecmpbll has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
User458764 has joined #ruby
User458764 has quit [Client Quit]
<apeiros>
!fixcon User458764
aniarya82 has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
kapil___ has quit [Quit: Connection closed for inactivity]
nowhereman_ has quit [Remote host closed the connection]
ferhaty has quit [Quit: ferhaty]
nowhereman_ has joined #ruby
ferhaty has joined #ruby
AJA4350 has joined #ruby
wildermind has joined #ruby
ferhaty has quit [Quit: ferhaty]
alex`` has joined #ruby
plutes has quit [Ping timeout: 244 seconds]
alex`` has quit [Client Quit]
ciro has joined #ruby
ArahaelPi has quit [Quit: 17]
arahael1 has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
gigetoo has joined #ruby
kapil___ has joined #ruby
arahael1 is now known as ArahaelPi
nowhereman_ has quit [Remote host closed the connection]
nowhereman_ has joined #ruby
dellavg has joined #ruby
Emmanuel_Chanel has joined #ruby
nowhereman_ has quit [Ping timeout: 256 seconds]
sylario has joined #ruby
gheegh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dellavg has quit [Ping timeout: 260 seconds]
gheegh has joined #ruby
dellavg has joined #ruby
gheegh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
savolla has joined #ruby
mojtaba has joined #ruby
banisterfiend has joined #ruby
GodFather has joined #ruby
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
thy0 has joined #ruby
dviola has joined #ruby
DLSteve has joined #ruby
Pip has joined #ruby
GodFather has quit [Ping timeout: 265 seconds]
GodFather has joined #ruby
kevinsjoberg has joined #ruby
MyMind has quit [Ping timeout: 240 seconds]
Rootsudo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Rootsudo has joined #ruby
Rootsudo has quit [Client Quit]
Rootsudo has joined #ruby
Rootsudo has quit [Client Quit]
Rootsudo has joined #ruby
Rootsudo has quit [Client Quit]
Rootsudo has joined #ruby
Rootsudo has quit [Client Quit]
Rootsudo has joined #ruby
Rootsudo has quit [Client Quit]
banisterfiend has joined #ruby
aniarya82 has joined #ruby
dviola has quit [Quit: WeeChat 2.2]
banisterfiend has quit [Ping timeout: 272 seconds]
<havenwood>
mike1, oh - they left
<havenwood>
Anyways, if they read the logs - make Offence#initialize take notes so you don't have to shovel them on, then:
<apeiros>
and put the hash into a constant instead of inline
<apeiros>
IMO you should use {nil => "development"} and no default in the fetch, though. that way it raises if it's set to an invalid value.
<sagax>
wow
<sagax>
apeiros: thanks
<sagax>
it's great
nowhereman_ has joined #ruby
mike11 has joined #ruby
<canton7>
(btw, try and avoid unless...else - it tends to do people's heads in
<canton7>
sagax, another way of writing that would be `env = "development" if !ENV.has_key?("NODE_ENV") || !["production", "development", "test"].include?(ENV["NODE_ENV"])`
<havenwood>
If someone sets ENV to something else, like "prodmuction" - I'd rather fail than have it silently be "development".
ciro has joined #ruby
fmcgeough has quit [Quit: fmcgeough]
yorickpeterse has quit [Quit: WeeChat 2.2]
ciro has quit [Ping timeout: 256 seconds]
mojtaba has joined #ruby
dellavg has quit [Remote host closed the connection]
DTZUZU has quit [Quit: WeeChat 1.9]
Dbugger has quit [Ping timeout: 265 seconds]
dellavg has joined #ruby
<sagax>
thanks all!
scientes has quit [Disconnected by services]
duderonomy has joined #ruby
mroutis has joined #ruby
rippa has joined #ruby
DTZUZU has joined #ruby
improv42 has quit []
<mike11>
hello all :)
<mike11>
I am looking for a way to express the following operation in a functional manner (i.e. using map, reduce, ...etc) http://rextester.com/YKA63660
<Zarthus>
can you describe the goal
<mike11>
Basically, I am mapping each element to an array that contains it. Except when the element is less than 10, it is appended to the last element's array
<Zarthus>
but your desired output is [[20, 2, 3], [30, 3, 4], [40, 4, 5]]?
<mike11>
Zarthus: exactly, and I am guaranteed that the input array's first element is not less than 10
psychicist__ has joined #ruby
<Zarthus>
ah, i see now, L6 adds a new array
<mike11>
Zarthus: I have committed similar code into production yesterday, but I feel about it :p
<mike11>
feel bad*
* Zarthus
shrugs
ciro has joined #ruby
<canton7>
Mike11, Enumerable#slice_before
<mroutis>
it's not that bad, Mike11, being functional not translates into good-quality-handcrafted-by-artisan code
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dellavg has quit [Ping timeout: 240 seconds]
ellcs has joined #ruby
mroutis has quit [Ping timeout: 244 seconds]
ShekharReddy has quit [Quit: Connection closed for inactivity]
ellcs has quit [Ping timeout: 265 seconds]
herbmillerjr has quit [Quit: Konversation terminated!]
mojtaba has quit [Quit: Leaving.]
ur5us has joined #ruby
mroutis has joined #ruby
aphprentice_ has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
dionysus69 has joined #ruby
kapil___ has quit [Quit: Connection closed for inactivity]
dionysus69 has quit [Ping timeout: 244 seconds]
GodFather has quit [Ping timeout: 240 seconds]
wildermind has joined #ruby
aniarya82 has quit [Quit: My MacBook Air has gone to sleep. ZZZzzz…]
this_dude has joined #ruby
fmcgeough has joined #ruby
<this_dude>
ok guys
<this_dude>
im gonna do my last attempt for this exam
<this_dude>
who's online
<baweaver>
who's not?
<this_dude>
hehe
<this_dude>
ok here goes
<this_dude>
actually let me do a couple practice problems to warm up
<this_dude>
omg so i found a group here looking for a ruby developer
<this_dude>
how do i make a coding resume??
<this_dude>
or portfolio
clemens3 has quit [Ping timeout: 244 seconds]
<Radar>
GOOD MORNING
<Radar>
this_dude: github.com
<Radar>
?next
<ruby[bot]>
Radar: I don't know anything about next
<baweaver>
ohai Radar
<Radar>
Yes it is I, the Radar.
fmcgeough has quit [Quit: fmcgeough]
<Radar>
this_dude: protip: if you're going to make a coding portfolio for Ruby, you should probably stop avoiding using blocks / procs / enumerable methods.
<havenwood>
this_dude: See github.com/ONE_OF_OUR_SCREEN_NAMES
<Radar>
this_dude: because if I was reviewing such a coding portfolio I would reject it because it is demonstrably bad Ruby.
<this_dude>
hehehe
<Radar>
Source: I am about to start reviewing a bunch of junior coding portfolios in a few weeks, with the aim of hiring 6 new junior Rubyists.
<this_dude>
gotta start somewhere i guess
<sagax>
why blocks and procs - it's bad?
<Radar>
Source: I also reviewed ~80 junior coding tests before and I have Mad Opinions™ about what Good Junior Ruby Code™ looks like.
<Radar>
sagax: he's writing .each loops using while instead.
<Radar>
i = 0; while i < things.length; things[i]; i += 1; end
<Radar>
instead of: things.each do |thing|; thing; end
<Radar>
yeah great you know how to do it the long way but if people are interviewing you based on that they're not interviewing you for your Ruby skills. They're interviewing more like for your obfuscation skills.
<sagax>
hm, it's bad, yes
<sagax>
ruby like as C ;D
<this_dude>
its cause c was the first language i learned hah
<Radar>
Yeah. It's not the _worst_ Ruby code, but it's not _quite_ Ruby as intended.
<this_dude>
hard to get away from old habbits
reber has quit [Remote host closed the connection]
<havenwood>
old hobbits too
<Radar>
(The worst Ruby code I used simultaneously ignored / over used the space bar and littered global variables throughout)
<sagax>
Frodo with ring
<Radar>
I reviewed used*
<this_dude>
hmm
<this_dude>
when removing the lowest number in an array
<this_dude>
can i not just.. arr.min.shift?
<this_dude>
oh wait no
<this_dude>
hold on
<this_dude>
arr.min.delete?
<baweaver>
What does min return?
<this_dude>
the lowest integer in the array
<baweaver>
yep, and do integers know how to delete?
<this_dude>
oh shoot no
<this_dude>
ok gonna go to my integer method dictionary brb
<this_dude>
wtf
<this_dude>
cant find anything
<baweaver>
yep. Now why would a number know how to delete something from an array?
<baweaver>
An array knows how to delete something from an array.
<this_dude>
arr.digits.map { |n| n.min.delete }
<this_dude>
?
<baweaver>
If you're calling digits, you're working on a number
<baweaver>
so calling it arr is odd.
<baweaver>
What does map do?
<this_dude>
you're right
<this_dude>
stores the values in an array to a hash
<Radar>
I plugged my exact question into Google and it tells me the answer "how do you remove the first element in array in Ruby?" -> boom first reuslt
duderonomy has joined #ruby
<this_dude>
oh
<this_dude>
numbers.delete_at[0](numbers.sort)
<Radar>
ok yeah you're intentionally being obtuse. I need a break bye.
<this_dude>
im NOT
<Radar>
I asked "what does google say?" to try to coax you towards the right action and you don't take it
<Radar>
did I just say check the documentation or did I just say check google?
<this_dude>
ok brb
<Radar>
Thank you.
blood has quit [Remote host closed the connection]
<this_dude>
ohhhh i thought it was shift thats where i was wrong
<this_dude>
i had .pop and .shift confused
blood has joined #ruby
<this_dude>
wait i am right pop is from the end
<this_dude>
google said pop
duderonomy has quit [Ping timeout: 244 seconds]
<this_dude>
UGH this is frustrating bc i know the answer is gonna be something so simple
<Radar>
[09:37:51] <Radar>I plugged my exact question into Google and it tells me the answer "how do you remove the first element in array in Ruby?" -> boom first reuslt
<Radar>
Ok, so we've got half the problem figured out. We know how to get the lowest value... well, one of the ways. But we need to not mutate the original array.
<Radar>
That will return you the lowest number without mutating the array.
<Radar>
Then your next task is to find the INDEX of the lowest number in that array.
<this_dude>
ok
* baweaver
is curious now
<Radar>
So you have the lowest number, you just need to find the index. With that index, then you can delete the object from the array.
<Radar>
Steps are: 1) find the lowest number [CHECK] 2) find one spot in the array where that number occurs [IN PROGRESS] 3) delete only the element at that location
<havenwood>
this_dude: I haven't looked at the problem. Just showing a dirty way to ask Ruby what it's method is that can do that thing. That's pretty easy when methods don't take arguments or blocks.
<havenwood>
If they take args, kwargs or blocks - you have to start fuzzing. ;-)
<this_dude>
oh
<havenwood>
this_dude: Remove the smallest numbers from an Array of numbers?
<this_dude>
yeah
<this_dude>
well no
<this_dude>
remove only the first instance of the smallest number of an array of numbers
<havenwood>
this_dude: And preserve the order?
<this_dude>
im gonna go resetup at a cowork space...be back in like 30
<this_dude>
correct
<this_dude>
ill check the chat log when i get back so feel free to comment while im afk :D