« Back to channel list

#ruby - 15 July 2017

« Back 1 day Forward 1 day »
[00:00:55] lamduh: has joined #ruby
[00:08:50] bkxd: has joined #ruby
[00:08:52] bkxd_: has joined #ruby
[00:10:34] eckhardt: has joined #ruby
[00:11:25] br0d1n: has joined #ruby
[00:23:11] chouhoulis: has joined #ruby
[00:25:26] rundor: has joined #ruby
[00:27:47] rundor_: has joined #ruby
[00:29:35] vondruch: has joined #ruby
[00:33:54] vondruch: has joined #ruby
[00:35:00] jackjackdripper: has joined #ruby
[00:37:23] __Yiota: has joined #ruby
[00:38:16] mim1k: has joined #ruby
[00:38:35] charliesome: has joined #ruby
[00:39:33] vondruch: has joined #ruby
[00:39:36] rundor: has joined #ruby
[00:41:52] rwb: has joined #ruby
[00:43:48] rundor_: has joined #ruby
[00:49:15] comet23: has joined #ruby
[00:49:20] comet23: what is a mature object?
[01:12:05] havenwood: comet23: hard to say without some context
[01:12:24] havenwood: comet23: why are you asking? where'd you hear that?
[01:12:50] bronson: has joined #ruby
[01:12:56] rivalomega: has joined #ruby
[01:13:16] rfoust: has joined #ruby
[01:13:24] havenwood: comet23: the only thing i can think is that you mean in terms of the GC? like it's young if it hasn't survived a sweep and mature if it has. is that what you mean?
[01:14:46] havenwood: (We actually have a tricolor GC now.)
[01:16:00] hahuang65: has joined #ruby
[01:16:35] contradictioned: has joined #ruby
[01:21:18] kculpis: has joined #ruby
[01:24:30] TunaBee: has joined #ruby
[01:25:44] AX31_A13X: has joined #ruby
[01:26:37] Azure: has joined #ruby
[01:29:32] iomotoko: has joined #ruby
[01:33:11] _whitelogger: has joined #ruby
[01:35:22] gizmore|2: has joined #ruby
[01:37:48] zapata: has joined #ruby
[01:39:14] reino4477: has joined #ruby
[01:39:23] reino4477: has left #ruby: ()
[01:41:44] ascarter: has joined #ruby
[01:42:44] lacuna: has joined #ruby
[01:46:13] reino44771: has joined #ruby
[01:46:17] reino44771: has left #ruby: ()
[01:54:48] d^sh: has joined #ruby
[01:55:04] milardovich: has joined #ruby
[01:59:01] daivyk: has joined #ruby
[02:03:08] duderonomy: has joined #ruby
[02:06:10] graft: has joined #ruby
[02:06:10] graft: has joined #ruby
[02:09:15] cyfr0n: has joined #ruby
[02:11:00] blackwind_123: has joined #ruby
[02:19:41] ecuanaso: has joined #ruby
[02:26:36] AxelAlex: has joined #ruby
[02:34:46] govg: has joined #ruby
[02:35:15] milardovich: has joined #ruby
[02:37:43] vondruch: has joined #ruby
[02:38:44] mim1k: has joined #ruby
[02:41:34] vondruch: has joined #ruby
[02:44:40] rubycoder37: would it be ok to use BigDecimal for currency?
[02:45:40] lamduh: has joined #ruby
[02:46:59] guardianx: has joined #ruby
[02:49:49] vondruch: has joined #ruby
[02:50:21] bkxd: has joined #ruby
[02:50:23] bkxd_: has joined #ruby
[02:50:37] hightower2: has joined #ruby
[02:53:27] vondruch: has joined #ruby
[02:56:45] eightlimbed: has joined #ruby
[02:57:35] vondruch: has joined #ruby
[03:02:39] jdawgaz: has joined #ruby
[03:02:46] hotpancakes: has joined #ruby
[03:13:44] bronson: has joined #ruby
[03:17:55] hahuang65: has joined #ruby
[03:21:41] SteenJobs_: has joined #ruby
[03:22:45] bkxd: has joined #ruby
[03:23:04] bkxd_: has joined #ruby
[03:25:11] ledestin: has joined #ruby
[03:25:35] rundor: has joined #ruby
[03:26:20] rundor: has joined #ruby
[03:27:10] rundor: has joined #ruby
[03:27:45] bkxd: has joined #ruby
[03:27:56] rundor: has joined #ruby
[03:28:44] bkxd_: has joined #ruby
[03:28:46] rundor: has joined #ruby
[03:34:13] hndk: has joined #ruby
[03:34:42] Jameser: has joined #ruby
[03:36:38] ahrs: has joined #ruby
[03:42:05] kies: has joined #ruby
[03:43:03] SteenJobs_: has joined #ruby
[03:43:38] ascarter: has joined #ruby
[03:48:42] guardianx: has joined #ruby
[03:50:09] comet23: havenwood, thank you for your reply
[03:50:14] szymon: has joined #ruby
[03:50:32] comet23: I am seriously studying ruby seriously and I wanted to understand more about mature vs primitive objects
[03:52:37] comet23: how can i use the attr_accessor here to shorten my code?
[03:52:37] comet23: https://repl.it/J2pO/0
[03:54:09] gix: has joined #ruby
[03:55:24] Guest93058: and why you initialize page count that mean you must give a page count
[03:55:40] comet23: oh i didn't know htat
[03:55:52] comet23: i thought i have to initialize everything that i am going to be using in the class
[03:57:59] Guest93058: https://repl.it/J2pO/1
[03:59:22] comet23: what are lines 42 and 44 doing?
[03:59:39] Guest93058: open irb and do
[04:01:30] comet23: okay, i see
[04:01:38] comet23: why would i want to do that?
[04:01:48] comet23: why not just set the page count to 1 as a default value?
[04:01:58] comet23: why create a separate method for it?
[04:03:17] ajnulo: has joined #ruby
[04:03:22] Guest93058: becouse you dont need use instant varible you t will have page_count not @page_count
[04:04:39] AxelAlex: has joined #ruby
[04:06:51] jeffreylevesque_: has joined #ruby
[04:10:58] comet23: how can i assign return values to getter and setter methods using the metaprogramming?
[04:10:59] runescape07rsps: has joined #ruby
[04:11:10] comet23: like attr_accessor :title for example
[04:11:25] comet23: i want that to return the initialized title instance @title
[04:11:46] comet23: or have it set a title by the user
[04:14:36] AnoHito: has joined #ruby
[04:15:36] jdawgaz: has joined #ruby
[04:16:26] jdawgaz: has joined #ruby
[04:16:53] Guest93058: ok i do some error so i try to rebuid and her you go
[04:16:56] Guest93058: https://repl.it/J2pO/11
[04:17:19] hotpancakes: has joined #ruby
[04:17:27] CuriousDude: has joined #ruby
[04:17:27] ChanServ: +b CuriousDude!*@*
[04:17:27] ChanServ: ChanServ kicked curiousdude: troll, bad mannered
[04:17:28] ruby[bot]: -b+b CuriousDude!*@* CuriousDude!*@*$#ruby-banned
[04:21:11] _whitelogger: has joined #ruby
[04:22:46] hotpancakes: has joined #ruby
[04:27:41] vondruch: has joined #ruby
[04:29:50] tohsaka: has joined #ruby
[04:32:48] eadthem: has joined #ruby
[04:33:27] eadthem: im getting incompatible character encodings: UTF-8 and ASCII-8BIT on a line of code. I want the varables involved to operate in 'BINARY'.
[04:33:38] eadthem: Im new to ruby, and im not having much luck with force_encoding
[04:34:13] eadthem: the orignal line throwing the message was buffer << ([ret].pack('V')) * 2
[04:34:55] eadthem: i added a buffer = buffer.force_encoding("BINARY") above it. but it didnt help
[04:35:28] eadthem: It would be nice if ruby would say which varable is which encoding type. My understanding is that pack('V') would be binary.
[04:35:40] matthewd: eadthem: Where is buffer coming from?
[04:35:51] matthewd: >> [0].pack('V').encoding
[04:35:53] ruby[bot]: matthewd: # => #<Encoding:ASCII-8BIT> (https://eval.in/832862)
[04:36:45] bkxd: has joined #ruby
[04:36:47] bkxd_: has joined #ruby
[04:36:58] eadthem: buffer = "USER" buffer <<"\x90" * 265 #(290 - code.lenght)
[04:37:09] mrconfused: has joined #ruby
[04:37:12] eadthem: thats the start of buffer, and the line following
[04:37:44] synion: has joined #ruby
[04:38:25] matthewd: You might want "USER".b
[04:39:16] mim1k: has joined #ruby
[04:39:59] matthewd: (though force_encoding should give you the same result)
[04:40:26] eadthem: ASCII-8BIT my understanding is the same as BINARY
[04:41:20] matthewd: Are you sure it didn't help? e.g. maybe the error just moved to a different line?
[04:41:47] eadthem: diffrent line number, but same line. .b didnt help ither
[04:42:13] eadthem: can i drop .encoding in spots to have it output debug info on what encoding type things are
[04:42:22] eadthem: prob with a puts id bet
[04:42:32] synion__: has joined #ruby
[04:43:16] johnny56_: has joined #ruby
[04:43:30] matthewd: #p is often more informative than #puts, but yeah, that's where I'd be going
[04:44:16] hotpancakes: has joined #ruby
[04:45:42] synion: has joined #ruby
[04:49:32] eadthem: oh good. buffer and ([ret].pack('V')) * 2 say Encoding:ASCII-8BIT
[04:49:50] eadthem: :p adding that stuff made it jump down a line
[04:50:53] charliesome: has joined #ruby
[04:51:33] synion__: has joined #ruby
[04:52:25] eadthem: there isnt a way to turn off encoding checks, or force everything to BINARY is there?
[04:52:44] eadthem: Literaly im adding .force_encoding('BINARY') to every line,
[04:53:42] eadthem: got it to work
[04:54:11] uZiel: has joined #ruby
[04:56:03] comet23: how can i https://repl.it/J2tJ/0 without default arguments in the initializer?
[04:58:05] elomatreb: comet23: You probably want keyword arguments
[04:58:23] matthewd: eadthem: You might prefer to pack all the strings as well
[04:58:38] milardovich: has joined #ruby
[04:58:38] eadthem: tbh not sure if i do.
[04:58:56] eadthem: the test didnt work, so this is not the script im looking for.
[04:59:09] eadthem: but this is the first ive ever touched ruby.
[04:59:27] eadthem: c++ c ASM and php are my usual languiges
[04:59:47] sniffer: has joined #ruby
[05:01:43] knight33: has joined #ruby
[05:03:57] Tau: has joined #ruby
[05:04:08] Tau: is eventmachine still in use? i mean is it still hot?
[05:04:16] Tau: or are there any other choices?
[05:04:41] jdawgaz: has joined #ruby
[05:04:51] tohsaka_: has left #ruby: ("Leaving")
[05:04:55] tohsaka_: has joined #ruby
[05:05:10] matthewd: tau: Depends what you want to do
[05:05:32] Tau: mattewd lets say an ircbot
[05:05:42] tohsaka_: unzip intern.hct -d ~/.config/hexchat
[05:05:51] tohsaka_: woops sorry
[05:08:09] comet23: Thank you everyone
[05:08:17] comet23: I figured it out and it was much simpler than I thought
[05:08:22] comet23: Have a great night I'm off to bed
[05:10:49] matthewd: tau: If you specifically want something that can handle multiple connections per thread, you might look at nio4r, or async/socketry (I'm not familiar with those, but I believe they're in the same solution space). But unless you're making an IRC *server*, I'd personally just go with a straight threaded model.
[05:12:20] Tau: mattewd i'll consider that.
[05:14:33] noe: has joined #ruby
[05:15:31] bronson: has joined #ruby
[05:17:43] Bock: has joined #ruby
[05:18:56] apparition: has joined #ruby
[05:19:02] hahuang65: has joined #ruby
[05:37:52] mim1k: has joined #ruby
[05:43:06] hahuang65: has joined #ruby
[05:43:56] hndk: has joined #ruby
[05:48:29] bkxd: has joined #ruby
[05:50:51] bkxd_: has joined #ruby
[05:55:50] bkxd: has joined #ruby
[05:57:22] bkxd_: has joined #ruby
[05:57:48] vondruch: has joined #ruby
[06:08:10] uZiel: has joined #ruby
[06:12:36] hahuang65: has joined #ruby
[06:15:20] andrzejku: has joined #ruby
[06:15:41] hotpancakes: has joined #ruby
[06:33:34] Timba-as: has joined #ruby
[06:41:00] konsolebox: has joined #ruby
[06:47:04] ruby-lang683: has joined #ruby
[06:48:08] ruby-lang683: can anyone have a quick gander at my code if i put it on gist? its angry about some `end` i have, but i'm pretty sure i need it
[06:48:37] elomatreb: Post it, if someone has time they will respond
[06:50:22] ruby-lang683: https://gist.github.com/Cyan101/d7f85c0f862c0a56194bbb26df901028 i put the error in the comments
[06:50:56] elomatreb: Oh, the error occurs because there is no "++" in Ruby
[06:51:06] elomatreb: In line 34, replace that with += 1
[06:52:33] guardianx: has joined #ruby
[06:56:04] milardovich: has joined #ruby
[07:07:20] guardianx: has joined #ruby
[07:09:26] hahuang65: has joined #ruby
[07:16:27] bronson: has joined #ruby
[07:34:01] hotpancakes: has joined #ruby
[07:36:12] guardianx: has joined #ruby
[07:41:38] cagomez: has joined #ruby
[07:46:15] hahuang65: has joined #ruby
[07:46:23] Inoperable: has joined #ruby
[07:46:47] AnoHito: has joined #ruby
[07:48:02] cjk101010: has joined #ruby
[07:49:29] surrounder: has joined #ruby
[07:49:36] vondruch: has joined #ruby
[07:53:43] vondruch: has joined #ruby
[07:54:38] dionysus69: has joined #ruby
[07:57:09] guardianx: has joined #ruby
[08:03:58] ur5us: has joined #ruby
[08:05:58] InfinityFye: has joined #ruby
[08:11:54] dn`: has joined #ruby
[08:18:14] vuoto: has joined #ruby
[08:20:48] biberu: has joined #ruby
[08:33:48] koenrh: has joined #ruby
[08:34:25] nofxxx: has joined #ruby
[08:39:55] hotpancakes: has joined #ruby
[08:43:17] cagomez: has joined #ruby
[08:45:52] dionysus70: has joined #ruby
[08:59:07] Ishido: has joined #ruby
[08:59:14] cagomez: has joined #ruby
[08:59:23] alex``: has joined #ruby
[09:00:44] jdawgaz: has joined #ruby
[09:04:32] Cyrus: has joined #ruby
[09:12:48] apparition: has joined #ruby
[09:17:28] bronson: has joined #ruby
[09:21:30] vondruch: has joined #ruby
[09:31:26] charliesome: has joined #ruby
[09:32:19] daivyk: has joined #ruby
[09:35:32] SteenJobs_: has joined #ruby
[09:38:02] rohitpaulk: has joined #ruby
[09:45:11] hotpancakes: has joined #ruby
[09:46:49] roshanavand: has joined #ruby
[09:48:51] ascarter: has joined #ruby
[09:51:23] lxsameer: has joined #ruby
[10:09:35] blackwind_123: has joined #ruby
[10:15:34] rohitpaulk: has joined #ruby
[10:16:29] cagomez: has joined #ruby
[10:21:16] roshanavand: has joined #ruby
[10:21:46] vondruch: has joined #ruby
[10:25:00] blackwind_123: has joined #ruby
[10:25:34] cseder: has joined #ruby
[10:27:26] vondruch: has joined #ruby
[10:31:15] mikecmpbll: has joined #ruby
[10:31:41] vondruch: has joined #ruby
[10:32:38] rohitpaulk: has joined #ruby
[10:40:01] blackwind_123: has joined #ruby
[10:41:50] vondruch: has joined #ruby
[10:42:38] Mia: has joined #ruby
[10:47:28] vondruch: has joined #ruby
[10:47:36] cagomez: has joined #ruby
[10:50:10] hotpancakes: has joined #ruby
[11:03:30] cagomez: has joined #ruby
[11:19:04] bronson: has joined #ruby
[11:23:17] runescape07rsps: has joined #ruby
[11:25:22] xdc: has joined #ruby
[11:25:57] xdc: has joined #ruby
[11:27:47] vondruch: has joined #ruby
[11:28:08] xdcc: has joined #ruby
[11:31:27] vondruch: has joined #ruby
[11:34:12] cagomez: has joined #ruby
[11:35:34] vondruch: has joined #ruby
[11:54:42] hotpancakes: has joined #ruby
[11:55:35] xdc: has joined #ruby
[11:57:52] Jameser: has joined #ruby
[12:00:11] xdcc: has joined #ruby
[12:03:44] vondruch: has joined #ruby
[12:04:07] ur5us: has joined #ruby
[12:05:09] BillyTheKid: has joined #ruby
[12:09:53] vondruch: has joined #ruby
[12:13:53] Jameser: has joined #ruby
[12:18:27] millerti: has joined #ruby
[12:21:44] Ishido: has joined #ruby
[12:23:02] jdawgaz: has joined #ruby
[12:27:56] hotpancakes: has joined #ruby
[12:28:02] lele: has joined #ruby
[12:33:44] Jameser: has joined #ruby
[12:33:58] sepp2k: has joined #ruby
[12:34:40] cadillac_: has joined #ruby
[12:37:16] Jameser: has joined #ruby
[12:45:33] vondruch: has joined #ruby
[12:45:53] dennisvennink: has joined #ruby
[12:48:03] cyfr0n: has left #ruby: ("Bye!")
[12:59:32] marr: has joined #ruby
[13:00:13] daivyk: has joined #ruby
[13:00:43] dionysus70: has joined #ruby
[13:00:55] Jameser: has joined #ruby
[13:03:56] el_ocho[m]: has joined #ruby
[13:03:56] Matt[m]4: has joined #ruby
[13:04:33] voltai[m]: has joined #ruby
[13:04:34] gokul_mr[m]: has joined #ruby
[13:04:55] jonjits[m]: has joined #ruby
[13:08:14] jeffreylevesque_: has joined #ruby
[13:11:09] rwb: has joined #ruby
[13:14:21] Jameser: has joined #ruby
[13:16:47] dionysus69: has joined #ruby
[13:19:40] bronson: has joined #ruby
[13:40:21] minimalism: has joined #ruby
[13:41:38] knight33: has joined #ruby
[13:47:08] jdawgaz: has joined #ruby
[13:50:00] theunraveler: has joined #ruby
[13:50:34] jdawgaz: has joined #ruby
[13:51:24] jdawgaz: has joined #ruby
[13:51:56] Tau: has joined #ruby
[13:52:12] Tau: has left #ruby: ()
[13:53:35] jeffreylevesque_: has joined #ruby
[14:01:46] t-recx: has joined #ruby
[14:05:47] bkxd: has joined #ruby
[14:05:49] bkxd_: has joined #ruby
[14:08:01] jeffreylevesque_: has joined #ruby
[14:08:44] rohitpaulk: has joined #ruby
[14:13:42] vondruch: has joined #ruby
[14:15:41] br0d1n: has joined #ruby
[14:16:12] comet23: has joined #ruby
[14:16:16] comet23: why are constants mutable?
[14:17:58] apeiros: because matz decided they should be
[14:18:59] apeiros: also note that "constant" means "references the same object constantly" (though you can even assign a new object to a constant, all you get is a warning - or you can use remove_const+const_set)
[14:20:52] ytti: ruby philosophically wants to allow maximum metaprogramming
[14:21:06] ytti: it is definitely double edged sword
[14:21:24] ytti: but in this philosophy it would be silly to completely remove ability to do something
[14:21:39] ytti: you may be using library which is using const, which shouldn't be const
[14:21:50] ytti: and you'll avoid forking that library with bit of nasty monkey patching
[14:22:01] ytti: not inherently good or bad, just one philosophy
[14:23:39] cam27: has joined #ruby
[14:25:12] Jameser: has joined #ruby
[14:27:30] rivalomega: has joined #ruby
[14:28:26] Silthias: has joined #ruby
[14:28:52] eightlimbed: has joined #ruby
[14:28:59] Silthias: has left #ruby: ()
[14:35:23] comet23: How can I improve this method?
[14:35:24] comet23: def brand=(name)
[14:35:24] comet23: BRANDS << name if BRANDS.include?(name) == false
[14:35:30] comet23: https://repl.it/J3Rk
[14:36:40] bronson: has joined #ruby
[14:37:10] vuoto: has joined #ruby
[14:38:41] Dimik: has joined #ruby
[14:39:21] jeffreylevesque_: has joined #ruby
[14:43:41] Papierkorb: comet23: use `unless` instead of `if`
[14:44:29] Papierkorb: comet23: Also, it might not be obvious at all to a user that `brand=` doesn't set the brand, but adds it to a constant, which is also highly questionable
[14:45:04] comet23: is this a highly questionable method too?
[14:45:05] comet23: def genre=(genre)
[14:45:23] Papierkorb: comet23: This is much more obvious, and also better to test: `def add_brand(name); @brands << name unless @brands.include?(name); end`
[14:45:28] comet23: https://repl.it/J3SS
[14:45:55] Papierkorb: Yes I wouldn't want that method in my code base.
[14:46:31] comet23: what would you use instead?
[14:47:27] Papierkorb: Hard to say without context. But writer methods (as in `foo=`) are generally expected to just set a value, maybe a sanity check on the new value, but that's really it it should do.
[14:47:37] Papierkorb: Also, changing the value of a CONSTANT is never a great idea
[14:47:50] bronson: has joined #ruby
[14:49:02] comet23: but as I understood just now a constant in Ruby is unlike other languages... it simply means a variable that is constantly accessed
[14:49:35] Papierkorb: Ruby allows to do pretty much anything. Doesn't mean it's a good idea to do that "pretty much anything" though.
[14:49:58] Papierkorb: And a CONSTANT is constant. Hence the name. If you need something that is variable in value, use a variable.
[14:50:13] apeiros: ACTION disagrees
[14:50:23] apeiros: and seems matz to
[14:50:23] comet23: apeiros said that a constant is variable that is constantly accessed
[14:50:30] apeiros: not constantly accessed
[14:50:35] apeiros: constantly referencing the same object
[14:50:43] comet23: what's the difference?
[14:50:47] apeiros: but even that is only a half-truth in ruby
[14:52:18] apeiros: comet23: if this wording isn't clear to you, then I don't know how to explain. maybe you need somebody who can translate both to your mother tongue.
[14:52:32] apeiros: Papierkorb: anyway, if you want immutable objects, #freeze is the way to go
[14:52:35] comet23: i thought everything is an object in ruby
[14:52:50] comet23: so that is why i am confused
[14:52:54] apeiros: code isn't. variables aren't. methods aren't.
[14:52:58] Papierkorb: apeiros: Yeah I generally freeze anything in a constant, if possible
[14:53:12] apeiros: you can get an object representing a method, though
[14:53:28] apeiros: blocks aren't either. but you can turn them into Proc instances.
[14:53:59] comet23: the difference between a class and an object is that an object is a name for a class that has been initialized?
[14:54:06] rkellermeyer: has joined #ruby
[14:54:39] apeiros: classes are objects
[14:54:44] comet23: class = blueprint and object = initialized blueprint?
[14:54:50] comet23: this is so confusing
[14:55:00] comet23: just when i thought i understood stuff
[14:55:02] apeiros: the difference between non-class objects and classes is that the class of a non-class object isn't a subclass of Class
[14:55:24] apeiros: err, *is* a subclass
[14:55:36] comet23: so what is the difference between a class and an object
[14:55:53] apeiros: all objects are instances of their class
[14:56:02] apeiros: Array.new.instance_of?(Array)
[14:56:11] apeiros: Array.is_a?(Class) # => true
[14:56:15] comet23: okay great, i was right
[14:56:17] apeiros: Array.new.is_a?(Class) # => false
[14:56:26] comet23: but that's not what i said?
[14:56:27] apeiros: but: Array.is_a?(Object) # => true
[14:56:44] Papierkorb: comet23: A constant is not totally unlike a variable: Both point to an object. Consider this code: `a = "hello"; b = a; b << " you"; puts a` - In here, a and b both point (or refer) to the same object (A String in this case). That's why we split the definition of a variable from a value, because many things can refer to the same value at any given time. A CONSTANT and a variable both refer to a value. The key difference now is a constant in
[14:56:46] Papierkorb: itself is constant: It always refers to the same value (might be any object). Consider this code: `FOO = "hi"; bar = "ho"` You can't change what FOO refers to afterwards (*), but you can easily what bar refers to afterwards. { (*) = Of course, ruby being ruby, you can change it. Avoid if possible. }
[14:57:35] apeiros: comet23: and yes, classes are the blueprints
[14:57:46] apeiros: what you said was slightly wrong because it implied classes weren't objects.
[14:57:50] vuoto: has joined #ruby
[14:58:14] comet23: i thought they weren't until they became instances of some variable
[14:58:26] apeiros: nothing becomes an instance of a variable
[14:58:34] apeiros: the only things which have instances are classes
[14:58:36] Papierkorb: comet23: However, as a constant points to an object, you can /change/ the state of this object. `FOO = []; FOO << "hi"` Is valid: You don't change what FOO points to (It's still the same Array object in this case!), but you change the state of the pointed-to (referred-to) array.
[14:58:41] apeiros: variables only *reference* things
[14:58:45] comet23: i mean before dong bike = Bike.new()
[14:58:47] apeiros: and those things are objects
[14:59:08] apeiros: and those objects can be classes
[14:59:19] apeiros: and classes are usually assigned to constants. they don't have to be, though.
[14:59:39] apeiros: >> @my_array_class = Class.new(Array); @my_array_class.new.is_a?(@my_array_class)
[14:59:40] ruby[bot]: apeiros: # => true (https://eval.in/832974)
[14:59:51] apeiros: >> @my_array_class = Class.new(Array); @my_array_class.is_a?(Class)
[14:59:52] ruby[bot]: apeiros: # => true (https://eval.in/832975)
[15:00:07] apeiros: >> x = Array; x.new
[15:00:13] ruby[bot]: apeiros: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
[15:00:16] apeiros: >> x = Array; x.new
[15:00:21] ruby[bot]: apeiros: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
[15:00:22] apeiros: ACTION hits eval.in
[15:00:32] apeiros: the result would be # => []
[15:00:52] apeiros: objects: things which you can assign to variables, and which you can invoke methods on.
[15:01:02] apeiros: *everything* where you call a method on is an object
[15:01:32] apeiros: note that with `foo = "hi"; foo.upcase!" you do NOT actually call "upcase!" on foo. you call it on the object referenced by foo.
[15:01:55] apeiros: we will colloquially say "call upcase! on foo". but that's because it'd be way too inconvenient to be precise all the time.
[15:02:35] apeiros: it becomes evident with e.g. this:
[15:02:46] apeiros: >> x = "hi"; y = x; y.upcase!; x
[15:02:48] comet23: Every time the interpreter sees " it creates a new instance of the String class and assigns it to that variable?
[15:02:51] ruby[bot]: apeiros: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `[]' for nil:NilClass
[15:02:56] apeiros: ACTION grumbled
[15:03:08] mrconfused: has joined #ruby
[15:03:35] apeiros: https://repl.it/languages/ruby
[15:03:43] apeiros: https://repl.it/J3TD
[15:03:57] bkxd: has joined #ruby
[15:03:58] bkxd_: has joined #ruby
[15:04:04] apeiros: yes, re "every time"
[15:04:15] apeiros: there are some optimized cases, but in general, this is true.
[15:04:54] apeiros: those are called literals. where the object is literally written in your code. it's not constructed e.g. from IO.
[15:05:18] apeiros: ACTION afk for a bit
[15:05:20] comet23: I want to impress my technical interviewers when I'm going out job hunting. I want them to see that someone without a college degree can be knowledgeable too. Thank you for your help
[15:05:26] comet23: Thank you so much :)
[15:08:54] duderonomy: has joined #ruby
[15:12:11] skweek: has joined #ruby
[15:16:02] pwned: has joined #ruby
[15:16:17] ule: Happy Saturday folks
[15:16:28] pwned: happy midsummer festival!
[15:17:28] ule: I'm reading the clean code from uncle bob.. trying to make connections with the ruby/rails world
[15:17:49] byte512: has joined #ruby
[15:19:09] watersoul: has joined #ruby
[15:19:51] hotpancakes: has joined #ruby
[15:20:34] andrewhl: has joined #ruby
[15:21:42] bkxd: has joined #ruby
[15:23:42] hndk: has joined #ruby
[15:29:41] aglorei: has joined #ruby
[15:30:43] Asher: has joined #ruby
[15:31:14] Harzilein: https://wiki.attraktor.org/images/0/05/I_tried_it_at_home.svg
[15:31:31] mim1k: has joined #ruby
[15:35:11] im0nde: has joined #ruby
[15:35:38] im0nde: has joined #ruby
[15:38:18] im0nde: has joined #ruby
[15:38:55] bkxd: has joined #ruby
[15:40:45] boombox_: has joined #ruby
[15:40:52] quobo: has joined #ruby
[15:41:44] comet23: has left #ruby: ()
[15:42:31] mim1k: has joined #ruby
[15:45:38] hotpancakes: has joined #ruby
[15:46:40] bkxd_: has joined #ruby
[15:48:56] ar1a: has joined #ruby
[15:50:05] mim1k: has joined #ruby
[15:52:05] dennisvennink: has joined #ruby
[15:53:46] kculpis: has joined #ruby
[16:01:01] nyuszika7h: has joined #ruby
[16:02:23] nyuszika7h: has joined #ruby
[16:02:41] rundor: has joined #ruby
[16:03:50] dionysus70: has joined #ruby
[16:04:50] theunraveler: has joined #ruby
[16:06:42] nyuszika7h: has joined #ruby
[16:13:33] rivalomega: has joined #ruby
[16:14:27] hotpanca_: has joined #ruby
[16:15:38] mim1k: has joined #ruby
[16:18:05] impermanence: has joined #ruby
[16:20:38] rohitpaulk: has joined #ruby
[16:21:07] impermanence: https://gist.github.com/jonassteinberg1/0698ee7936fc691341b4cd2d36e41c44
[16:21:23] impermanence: I'm studying the well grounded 2ed right now and I'm reading the threads overview section
[16:21:39] rkellermeyer: has joined #ruby
[16:21:48] impermanence: After copying and pasting the author's suggestion I don't get what he says should be stdout'ed
[16:21:51] impermanence: and I'm not sure why
[16:21:59] impermanence: Any insight would be greatly appreciated
[16:24:32] lxsameer: has joined #ruby
[16:27:28] apeiros: well, that's what can happen with threads…
[16:27:41] apeiros: lets change the code slightly so it's less dependent on chance :)
[16:27:43] impermanence: It *kinda* works in pry
[16:28:08] apeiros: https://gist.github.com/apeiros/840bfdb0b0cd0578e09a3e0e3e4d72ff
[16:28:17] impermanence: The first line is stdouted immediately but I can't tell if it's like "returning" it or stdouting it or...
[16:28:38] apeiros: printing is not returning
[16:28:53] apeiros: also that code alone will probably be insufficient
[16:29:27] apeiros: updated https://gist.github.com/apeiros/840bfdb0b0cd0578e09a3e0e3e4d72ff
[16:29:38] apeiros: without the thread.join, the "At the end of thread" won't be printed
[16:29:52] apeiros: since ruby only waits for the main thread to terminate, it doesn't care about other threads.
[16:29:53] impermanence: what you're saying surprises me because The Well Grounded is generally regarded as one of the finest books on Ruby every written (I think?)
[16:30:14] apeiros: I bet there are errata
[16:30:17] impermanence: not criticising anyone...I'm just like..."huh"...
[16:30:24] impermanence: oh yeah, bet you're right
[16:31:07] impermanence: yeah your second gist revision is where the author heads next
[16:31:29] impermanence: What is it about join that makes it the function we need to use (for threads)?
[16:31:42] impermanence: I usually only think about it in terms of strings and such
[16:31:50] apeiros: I guess the author wanted to demonstrate that "At the end of the thread" is not printed
[16:32:13] apeiros: Thread#join says "wait here until that thread has finished executing"
[16:32:29] apeiros: you can alternatively use Thread#value, which will also evaluate to the last value in the thread.
[16:32:43] apeiros: e.g. Thread.new { x = 3; y = 2; x+y }.value # => 5
[16:32:57] apeiros: &ri Thread impermanence
[16:33:10] apeiros: oy, derpy is dead :( poor bot
[16:33:23] impermanence: derpy is a legen name though, lol
[16:33:30] apeiros: and its master isn't around either! :-O
[16:33:47] impermanence: btw...the additional "sleep 0.5" from your first gist revision was enough to get that first puts to stdout
[16:34:10] apeiros: oh, thread moved to core? interesting: http://ruby-doc.org/core-2.4.1/Thread.html
[16:34:23] apeiros: impermanence: because threads run concurrently
[16:34:33] apeiros: and the sleep makes the main thread wait for half a second
[16:34:40] apeiros: so the thread you spawned has a chance to print first
[16:34:56] impermanence: oh. so like a thread fight?
[16:34:59] apeiros: if you don't sleep, the result is not really determined. it depends on what ruby schedules first.
[16:35:24] apeiros: it can even happen that the print operation is interleaved. then you get garbled output.
[16:36:07] apeiros: though, to ensure that two threads do NOT run concurrently, you shouldn't really ever use sleep. there are tools for that. e.g. Mutex. but I bet the author will get there too.
[16:36:10] apeiros: ACTION afk for a bit
[16:36:24] impermanence: so how does one write Ruby code that cooperates or intuits the scheduler?
[16:36:37] ttilley: has joined #ruby
[16:36:57] dasher00: has joined #ruby
[16:37:25] ttilley: has joined #ruby
[16:39:11] hotpancakes: has joined #ruby
[16:42:33] apeiros: impermanence: pretty sure the author will explain ;-)
[16:43:53] impermanence: yaa, reading the Thread class in core rn so I'm getting up to spizzeed.
[16:44:00] havenwood: impermanence: If you don't have any shared state it's not too bad at all!
[16:44:32] havenwood: impermanence: Jesse Storimer wrote a book on Ruby Threads that's a great introduction.
[16:44:46] havenwood: https://www.jstorimer.com/pages/books
[16:44:57] havenwood: "Working with Ruby Threads"
[16:46:52] havenwood: I'm excited over the possibility of Ruby getting green threads back, except this time auto-scheduled: https://bugs.ruby-lang.org/issues/13618
[16:47:18] havenwood: Like an Erlang process or Goroutine in Ruby.
[16:47:35] impermanence: havenwood: uh...I thought green threads were always a thing for Ruby though?
[16:48:03] havenwood: impermanence: Ruby had green threads in 1.8, but they could only use one core.
[16:48:45] havenwood: impermanence: Ruby started to map threads one-to-one to system threads in 1.9, but they're sometimes limited from running in parallel by the GVL (also called GIL).
[16:49:23] havenwood: impermanence: The green threads in 1.8 kinda became what is Fiber in 1.9, but they have to be scheduled by the programmer.
[16:49:32] universal: has joined #ruby
[16:49:39] bronson: has joined #ruby
[16:49:55] rohitpaulk: has joined #ruby
[16:49:59] impermanence: havenwood: wow, that Storimer link is excellent! I wish I had bought that Unix book he wrote instead of this other one I bought.
[16:50:04] havenwood: impermanence: normalperson implemented green threads for future Ruby that are evented, self-scheduling Fibers.
[16:50:08] hotpancakes: has joined #ruby
[16:50:16] havenwood: impermanence: They're great books. I recommend all three.
[16:54:52] mokiwis: has joined #ruby
[16:55:05] aglorei: has joined #ruby
[16:55:53] hndk: has joined #ruby
[16:56:00] _aeris_: has joined #ruby
[17:01:09] pmden: has joined #ruby
[17:06:00] eightlimbed: has joined #ruby
[17:10:18] mrconfused: has joined #ruby
[17:10:41] pmden: has joined #ruby
[17:13:44] nanoz: has joined #ruby
[17:15:32] eightlimbed: Does anyone know of a gem that handles audio recording? I'm looking for something that can pick up a recording and export a wav of flac file.
[17:21:07] jpinnix: has left #ruby: ()
[17:21:46] blackwind_123: has joined #ruby
[17:23:10] gheegh: has joined #ruby
[17:25:23] rundor: has joined #ruby
[17:27:40] Timba-as: has joined #ruby
[17:29:51] vondruch: has joined #ruby
[17:31:58] hotpancakes: has joined #ruby
[17:32:49] rundor: has joined #ruby
[17:32:52] patarr: has joined #ruby
[17:33:39] rundor: has joined #ruby
[17:34:22] rundor: has joined #ruby
[17:35:11] rundor: has joined #ruby
[17:36:05] hotpanca_: has joined #ruby
[17:36:06] rundor: has joined #ruby
[17:38:12] Antiarc: has joined #ruby
[17:41:03] gr33n7007h: has joined #ruby
[17:46:53] dasher00: has joined #ruby
[17:49:46] bronson: has joined #ruby
[17:51:07] Coldblackice: has joined #ruby
[18:11:12] _aeris_: has joined #ruby
[18:27:42] nadir: has joined #ruby
[18:29:13] Coldblackice: has joined #ruby
[18:29:22] impermanence: has joined #ruby
[18:31:40] vondruch: has joined #ruby
[18:34:45] uZiel: has joined #ruby
[18:35:47] sagax: has joined #ruby
[18:35:49] vondruch: has joined #ruby
[18:36:04] patarr: has joined #ruby
[18:39:46] centrx: has joined #ruby
[18:39:46] centrx: has joined #ruby
[18:44:38] hashrocket: has joined #ruby
[18:49:25] vondruch: has joined #ruby
[18:54:40] cyberRodent: has joined #ruby
[18:57:10] DeeJayh: has joined #ruby
[18:59:38] electrostat: has joined #ruby
[18:59:47] dviola: has joined #ruby
[19:07:30] alex``: has joined #ruby
[19:10:55] truenito: has joined #ruby
[19:11:38] Nahra``: has joined #ruby
[19:16:47] oleo: has joined #ruby
[19:23:22] cyberRodent: has joined #ruby
[19:23:42] DeeJayh: has joined #ruby
[19:24:45] xpedititon: has joined #ruby
[19:30:37] Thiru: has joined #ruby
[19:30:56] Vegitto: has joined #ruby
[19:33:34] TheBloke: has joined #ruby
[19:34:31] Vegitto: is ruby a cute language?
[19:35:03] Guest52: has joined #ruby
[19:36:34] Saifulapm: Hi, Can anyone help me ? How to use dclone() method ?
[19:38:52] apeiros: Vegitto: sure
[19:38:57] apeiros: Saifulapm: more context please
[19:39:25] Saifulapm: In ruby-lang website, I just found this
[19:39:27] Saifulapm: provides a unified clone operation, for REXML::XPathParser to use across multiple Object+ types
[19:39:54] apeiros: do you use REXML?
[19:40:32] Saifulapm: https://apidock.com/ruby/Array/dclone
[19:40:49] apeiros: that's not an answer to my question
[19:40:53] Saifulapm: No.. I don't know what is REXML .. I am learning Ruby
[19:40:53] apeiros: do you use REXML?
[19:41:02] apeiros: then you don't need dclone and probably don't have it
[19:41:21] Saifulapm: ok. But What is REXML ?
[19:41:30] apeiros: classes in ruby are open, means that any library can add additional methods to existing classes. rexml apparently adds dclone to Array (and probably others)
[19:41:56] apeiros: http://ruby-doc.org/stdlib-2.4.1/libdoc/rexml/rdoc/index.html
[19:42:08] apeiros: rexml is an xml parser shipping with ruby, it's part of its standard library
[19:43:04] apeiros: so maybe a better question now is: what did you want to use dclone for?
[19:44:03] apeiros: interesting answer to a "what" question…
[19:44:37] rgtk: has joined #ruby
[19:46:27] rgtk: has joined #ruby
[19:47:48] Nicmavr: has joined #ruby
[19:47:59] Saifulapm: I didn't find any use of dclone() in google. :(
[19:50:24] bronson: has joined #ruby
[19:54:07] apeiros: Saifulapm: what problem are you trying to solve?
[19:56:36] Saifulapm: Actually I am learning now Ruby from ruby-doc website. In Array class, I found this method. In Ruby doc , no example for this method. Also I have searched in google for example of this method. Just I am playing with Ruby
[19:56:53] roke: has joined #ruby
[19:57:41] aclark: has joined #ruby
[19:58:34] apeiros: read the core docs, not apidock
[19:58:46] apeiros: http://ruby-doc.org/core-2.4.1/
[19:59:16] houhoulis: has joined #ruby
[19:59:44] d4ybl1nd: has joined #ruby
[20:00:49] DeeJayh_: has joined #ruby
[20:07:07] vuoto: has joined #ruby
[20:08:08] Vircung: has joined #ruby
[20:09:36] vondruch: has joined #ruby
[20:10:02] xpedititon: has joined #ruby
[20:10:29] impermanence: has joined #ruby
[20:11:07] impermanence: has joined #ruby
[20:35:29] rohitpaulk: has joined #ruby
[20:38:56] cadillac__: has joined #ruby
[20:41:42] hays: has joined #ruby
[20:47:53] rubycoder37: I need to represent currency in decimal, is BigDecimal good enough?
[20:53:22] al2o3-cr: rubycoder37: yes, or just use Rational
[20:57:30] rubycoder37: ok, thank you
[20:59:05] Zarthus: or a string / two integers if your need is very basic
[20:59:21] Zarthus: (could be a single integer too if you calculate from cents)
[21:04:02] apeiros: rubycoder37: or the money gem
[21:06:39] impermanence: has joined #ruby
[21:11:53] quobo: has joined #ruby
[21:15:45] postmodern: has joined #ruby
[21:27:39] daivyk: has joined #ruby
[21:28:09] ecuanaso: has joined #ruby
[21:38:03] gnoss: has joined #ruby
[21:38:42] mim1k: has joined #ruby
[21:38:52] rivalomega: has joined #ruby
[21:39:12] rivalomega: has joined #ruby
[21:41:35] roshanavand: has joined #ruby
[21:43:34] yorickpeterse: I'm shocked there's no financial related gem called makeitrain
[21:47:30] ecuanaso: has joined #ruby
[21:51:19] bronson: has joined #ruby
[21:56:36] dasher00: has joined #ruby
[22:00:31] ruby[bot]: has joined #ruby
[22:00:31] ChanServ: +o ruby[bot]
[22:06:07] cam27_: has joined #ruby
[22:06:51] ur5us: has joined #ruby
[22:09:05] kobain: has joined #ruby
[22:14:51] rundor: has joined #ruby
[22:17:08] bruno-: has joined #ruby
[22:19:39] rivalomega: has joined #ruby
[22:23:36] nowhereman: has joined #ruby
[22:24:49] rivalomega: has joined #ruby
[22:26:25] rubycoder37: yorickpeterse: hah! I'm sure managers would love that one
[22:27:10] mjolnird: has joined #ruby
[22:27:53] hahuang65: has joined #ruby
[22:31:00] apeiros: makeatrain?
[22:32:31] mjolnird: has joined #ruby
[22:32:36] havenwood: t🚂🚋🚋
[22:34:41] mjolnird: has left #ruby: ()
[22:35:17] sepp2k: has joined #ruby
[22:36:02] misery_: has joined #ruby
[22:38:19] Sammichmaker: has joined #ruby
[22:40:39] rundor: has joined #ruby
[22:41:29] rundor: has joined #ruby
[22:42:14] rundor: has joined #ruby
[22:43:12] rundor: has joined #ruby
[22:43:37] jeffreylevesque_: has joined #ruby
[22:43:47] rundor: has joined #ruby
[22:45:10] ignarps: has joined #ruby
[22:55:46] bkxd: has joined #ruby
[22:55:48] bkxd_: has joined #ruby
[23:06:06] jdawgaz: has joined #ruby
[23:06:31] patarr: has joined #ruby
[23:10:41] zapata: has joined #ruby
[23:13:13] Guest62604: has joined #ruby
[23:13:34] Guest62604: Ruby is not the best language IMO
[23:14:01] Guest62604: Has anyone considered C?
[23:14:46] Guest62604: I just find it a bit slow
[23:15:17] Guest62604: C is really quite fast
[23:18:40] hays: has joined #ruby
[23:19:23] rubylegend2092: has joined #ruby
[23:20:13] rubylegend2092: has joined #ruby
[23:20:54] Guest62604: rubylegend2092, Have you considered C as your saviour?
[23:22:59] rubylegend2092: Yes, actually. I love C
[23:30:23] impermanence: has joined #ruby
[23:30:50] rubycoder37: that feeling when I realize that the application I wrote is smarter than myself
[23:33:31] apeiros: !troll Guest62604
[23:33:31] ruby[bot]: +bb Guest62604!*@*$#ruby-banned *!*@124.171.235.172$#ruby-banned
[23:33:32] ruby[bot]: ruby[bot] kicked Guest62604: is a bannable offense, see http://ruby-community.com/pages/user_rules
[23:34:05] alveric2: has joined #ruby
[23:38:25] bkxd: has joined #ruby
[23:39:09] jud: has joined #ruby
[23:39:11] bkxd_: has joined #ruby
[23:39:14] mim1k: has joined #ruby
[23:44:40] rwb: has joined #ruby
[23:52:38] bronson: has joined #ruby