Transcript from the "Intentional Coercion" Lesson
>> Kyle Simpson: You have to adopt a coding style that makes your types and the values that are in those types plain and obvious, that's the only effective way to do this.
[00:00:27] Some people goes so far as to used whole type systems, and we'll get into that a little bit later like TypeScript and stuff. I don't think you have to go that far but you can adopt a coding style which makes the kinds of types that you're doing much more obvious.
[00:01:00] You're asking for coercion problems when you do that and then papering over them, but I used the triple, I used the triple equals. Why not just design a function that only takes numbers and then make another function that only takes strings? Or make a function that takes numbers and strings, and it's very clear it can only be those two types, and I know what corner cases I have to worry about between numbers and strings.
[00:01:23] We can choose to be more obvious about how we manage our types, how much we overload, how polymorphic we make our code. We can opt in to more problems or opt out of problems as a result.
>> Kyle Simpson: Biggest takeaway that I want you to get here is that these are fact of your programs and it is within your purview to decide how much or how little you're gonna be affected by those facts.
>> Kyle Simpson: That is not to suggest that the only solution to our problem is that everything have to rigidly, everything's completely statically typed. We have to just basically go write Java or C Plus Plus so that we get some kind of like sound type system, that is a reaction to this problem, it is not the the reaction I think that is necessary.
[00:02:12] So the message I'm preaching here is you can learn these systems, use them appropriately and make them obvious in your code.
[00:03:04] And if you're not using it, your programs are missing out