#ruby - 30 June 2019
« Back 1 day Forward 1 day »
[14:13:02] ruby[bot]: chalkmonster: this seems to be off-topic. Please move your discussion to #ruby-offtopic, to keep this channel free for Ruby related problems. Thanks!
[15:25:47] ruby[bot]: -bbbb $a:flugzeug[m]$#ruby-banned NoNoNo!*@*$#ruby-banned RubyForGays!*@*$#ruby-banned RubySucks!*@*$#ruby-banned
[15:30:17] rubydoc: # => [Integer, Numeric, Comparable, Object, Kernel, BasicObject] (https://carc.in/#/r/75uu)
[15:42:47] havenwood: comet23: I'd recommend converting to what you need rather than manually checking class names.
[15:43:39] havenwood: comet23: Your line 10 is bug prone, since `total` might be an Integer, meaning #/ would round.
[15:46:09] havenwood: comet23: It's nice to use :ok and :error for Erlang-style return values. So `:error` instead of `"ERROR"`, though these days it matters less with frozen string literals available.
[15:46:30] havenwood: comet23: Typically, you'd `raise` in this case, after say a `to_int` conversion attempt.
[15:50:39] havenwood: comet23: Floats tend to be a mess to use. They're not just decimal numbers. They're fast, but there're enough gotchas they're problematic in many cases.
[15:53:07] havenwood: comet23: "Float objects represent inexact real numbers using the native architecture's double-precision floating point representation."
[15:53:18] havenwood: comet23: "Floating point has a different arithmetic and is an inexact number. So you should know its esoteric system."
[15:54:34] havenwood: "Decimal arithmetic is also useful for general calculation, because it provides the correct answers people expect–whereas normal binary floating point arithmetic often introduces subtle errors because of the conversion between base 10 and base 2."
[15:55:30] comet23: oh, that's very interesting... here i thought a float is the jargon for decimal numbers
[15:55:39] havenwood: comet23: BigDecimal will be the behavior you expect, where Float will seem wrong and bizarre if you're not familiar with binary floats.
[15:58:30] havenwood: comet23: I don't think new folk to programming should even be taught Floats. They're not particularly useful for most things.
[16:01:40] comet23: here's a float, floats are decimal numbers this is how you use them now go have fun :)
[16:01:49] havenwood: comet23: I'm not against learning about Floats at all. :) I just think they get introduced early on to new folk, when experienced folk aren't using them. We shouldn't introduce esoteric parts like Float and Matrix right up front.
[16:02:29] havenwood: No harm in using Float or Matrix or whatever else, but just because Floats look like decimal numbers isn't a good excuse to teach them to newcomers imho.
[21:16:38] leitz: Yay me! Just finished studying "Head First Ruby". Except for the appendix, which I'll get to shortly.
[22:34:39] leitz: Also spent some time on the question you asked, havenwood, about what projects I'm working on. Wrote them up in short form, and some of the questions and challenges.