3 ms·
Why would one choose this: var int_item = $(Int, 5); over this: int int_item = 5; What am I missing?
by ilitirit 13y ago
Why would one choose this:
var int_item = $(Int, 5);
over this:
int int_item = 5;
What am I missing?
- pmelendez 13y agoWell with the var option you do something like this: var item = $(Int, 5); ... code ... item = $(String, "5"); Not that you want to do that all the time but it is a way to implement duck typing
- JackdawX 13y agoA better example for duck typing would be something like: var my_func(var int_or_string, var int_or_obj) { ... return int_or_string_result; } Simplifies certain operations, complicates debugging. Great for small scripts though.