Today I Learned

TIL, 2017-03-04

  • GIL apparently exists
  • Overkill: Avoiding race conditions. Remember, instance variables stick around for the lifetime of the object. There is some state somewhere that at some point got out of whack. This can be minimized by using the proc on a case statement. You can use Procs on a case statement.
  • To remove the race condition though, you can create a new object to store the instance that was shared, ala:

    def hey(input)
      input = Input.new(input) # Calling `hey` while another thread is in the middle of calling `hey` would not called a stored @input instance_variable if this code was = @input = input and the case statements where switched on @input
    
      case
      when input.silence? ...
      when input.shouting?? ...
    
  • You really have to understand why errors are there, not just think of them as an annoyance that you want to remove. That’s why it’s there
  • Working with junior people, you have to structure your code with the assumption that they will follow how you do it
  • The concept of testing in a company, you don’t convince people, you just do it in stealth or find a co-conspirator. If they don’t want to, then you can leave.
  • Speaking of case statements, it evaluates on the === operator, which is “does this include”

This project is maintained by daryllxd