Fork me on GitHub
#off-topic
<
2015-11-16
>
johanatan00:11:12

@jaen: yea, don't know. My experience has been the exact opposite.

johanatan00:11:06

And I haven't needed a debugger in Clojure at all-- just test small snippets in REPL and paste them into source file. If something doesn't work, then I just use println/console.log

borkdude06:11:06

@johanatan: That's my experience too. I never use a debugger in Clojure, although it's possible now. I do use it in Ruby though, binding.pry.

borkdude09:11:58

what is the Ruby equivalent of apply?

borkdude09:11:11

say I've got a method foo(*v), and I want to call it with an array

borkdude09:11:37

probably Ruby has magic for this...

spariev10:11:44

@borkdude: try send(:foo, v)

borkdude10:11:32

just foo(v) works (Ruby magic ...)

nilbus11:11:30

To answer your original question though, foo(*v) is the equivalent of JS apply (it expands the array v to match the args accepted by foo)

nilbus11:11:27

* is the “splat” operator, which converts an arg list into an array and vice versa.

nilbus11:11:38

does the same for keyword args

borkdude11:11:20

What is a good name for a function that calculated the price after a possible reduction

nilbus13:11:44

That’s good. Or price_after_discount.

borkdude13:11:44

@nilbus: I only read this now, but that's exactly what I chose simple_smile

borkdude13:11:08

@nilbus: @agile_geek I didn't tell you this was Ruby, so _ is more appropriate

nilbus13:11:28

yay for my last-second realization and edit 😉

agile_geek13:11:59

@nimbus @borkdude as discount is a verb as well as a noun I thought discount the price i.e. discount_price was slightly better than price_after_discount which sounds like a field not a function? Happy to be contradicted tho

borkdude13:11:33

in this case it's actually a method on a model object

nilbus13:11:09

a field-like name for a method is good and normal in ruby

nilbus13:11:35

as long as there are no side effects

agile_geek13:11:28

could have used discounted_price as well

nilbus13:11:01

another good option

borkdude13:11:46

thanks guys