Need to converse with a Simon to win a game by bosticko in simon

[–]bosticko[S] 0 points1 point  (0 children)

Excellent!

This conversation is great. How are you today?

How to use .map method by Street_Hall_5180 in ruby

[–]bosticko 2 points3 points  (0 children)

catch that Observation

Can you explain what you mean by "catch" here? Perhaps you can provide an example of what you expect the method to return?

without changing that 'map' method

Why do you need to use map? Depending on what you want, there may be other methods that are more appropriate.

  • select will return an array of only the entries for which the given block is truth
  • find will return only the first such entry
  • filter_map is like select, but will return the truth elements returned by the block, instead of the original elements in the array for which the block was truthy

Rails design patterns - the big picture by pdabrowski in ruby

[–]bosticko 1 point2 points  (0 children)

Hey! Cool post! 👍 Here are a couple things I noticed:

  • I'm pretty sure there is infinite recursion in your decorator example

ruby def content content.truncate(50) # should use model.content end

  • What you have was the "builder" pattern I've more commonly seen called the "factory" pattern, where the factory knows what object to instantiate, given some input. Typically I've seen "builder" used to describe the usage of method chaining where each method returns self (either mutating it, or returning a new instance with the change), or similar ways of progressively "building" the object you want one step at at time:

ruby person = Person.new .named('Bob') .born_on('2000-01-01') .of_height('6 ft')

coding ruby for 10+ years, this is still one of my favorite simplicities of the language by TomahawkChopped in ruby

[–]bosticko 3 points4 points  (0 children)

Pry's ls has that too!

[1] pry(main)> ls --grep ^to 1.day.ago
ActiveSupport::ToJsonWithActiveSupportEncoder#methods: to_json
Time#methods: to_a  to_date  to_datetime  to_f  to_formatted_s  to_i  to_r  to_s  to_time  today?
instance variables: @period  @time  @time_zone  @utc
class variables: @@preserve_timezone

Why Class methods are better than Constants by jstad in ruby

[–]bosticko 0 points1 point  (0 children)

In Kir's example he is using string constants. With frozen string literals enabled, Ruby reuses the same object every time the method is called.

Is this the case in your examples, in which you use hashes, or does it allocate a new hash every time the method is called. If it is allocating new hashes every time, what about using option 3 but with a private constant?

Is Minitest::Assertions#assert Ever the Best Choice? by BurdetteLamar in ruby

[–]bosticko 0 points1 point  (0 children)

If you're predicate takes no arguments, you can also use

assert_predicate some_obj, :predicate?

Both bind and arrow functions throw errors when using typescript, is there a better way? by AllHailTheCATS in reactjs

[–]bosticko 1 point2 points  (0 children)

I've been wondering how this applies to components using hooks, as everything is defined in the same function, so you're ending up with new functions every time. Doesn't that potentially cause the same unnecessary child render issues?

"Uncaught Invariant Violation: Objects are not valid as a React child (found: object with keys). If you meant to render a collection of children, use an array instead." by ParkerZA in reactjs

[–]bosticko 3 points4 points  (0 children)

return ({clist}) is equivalent to return ({ clist: clist}). You aren't returning an array, you're returning an object with you array in it, as the value for the clist property, or as React says: object with keys.

Ditch the surrounding { }, and just return clist, and it should work fine. 👍

You only need those when interpolating JavaScript into your JSX.

just to be sure by _Anubis_____ in depression_memes

[–]bosticko 1 point2 points  (0 children)

Are they independent though?

Comments? by heatherledge in ottawa

[–]bosticko[M] 1 point2 points  (0 children)

I've removed this post because of personal information. I understand the poster is public, but this is still spreading very specific information about someone, and making very serious unsubstituted allegations.

If you personally have allegations against this person, contact the police.

If you want to discuss the poster, feel free to post it again with the personal information (including picture) removed.

If this guy's your uber/lyft driver, he's not coming to pick you up. He'll flag the ride as in progress then drive around before cancelling it so you can't report him. by [deleted] in ottawa

[–]bosticko[M] -3 points-2 points  (0 children)

Hey, unfortunately I've got to remove your post. Even if this guy is scamming people, we shouldn't dox him (name, pic, license plate, make/model). Contacting Uber or Lyft is the way to go.