Questions tagged [coercion]

Coercion, type conversion and typecasting are different ways of, implicitly or explicitly, changing an entity of one data type into another.

Coercion, type conversion and typecasting are different ways of, implicitly or explicitly, changing an entity of one data type into another.

398 questions
-1
votes
2 answers

TypeError: coercing to Unicode: need string or buffer, long found

class Movie(models.Model): movie_id = models.BigAutoField(primary_key=True) movie_name = models.CharField(max_length=128) movie_lang = models.CharField(max_length=36) director = models.CharField(max_length=72) producer =…
kartheek
  • 690
  • 6
  • 9
-1
votes
1 answer

Overcome the coercion of dataframe to a list when using sqldf

I need to classify the rows into two groups(Present or Not present) based on the values in the two columns Var1, Var2 in the dataframe pum. Later add this as a new column to another dataframe as data.cov.cat$PU. When Var1 greater than 0.053 or Var2…
Prradep
  • 5,506
  • 5
  • 43
  • 84
-1
votes
3 answers

Why +true is not equal to true.valueOf?

+true // result: 1 true.valueOf() // result: true +true === true.valueOf() // result: false In Javascript Type Coersion, the function called for evaluation is valueOf(). But if the function is called explicity it returns a different value.
Vijay
  • 11
  • 1
-1
votes
1 answer

Overloading Operators for Numeric Types in C#

I'm creating a numeric type called BigNum which is meant to be a really expandable BCD. In the process, I'm overloading most/all of the normal numeric operators. My main question is, do I need to overload each operator for each built-in numeric type…
Nakaan
  • 167
  • 7
-2
votes
1 answer

Can I declare an enum value that takes a String or &str without needing additional functions?

I have an enum with a String: enum MyLovelyEnum { Thing(String), } For tests, I would like to be able to pass in a &'static str to avoid MyLovelyEnum::Thing("abc".to_string) over and over. I found that you can do this nicely with structs with a…
John
  • 65
  • 5
-2
votes
1 answer

Difference between !typeof str == "string" and typeof str != "string"

I was writing a simple if condition that checks the type of the input. I used !typeof str == "string" it did not work, so i used typeof str != "string" instead of it. it worked. this is the function: function reverseStr(str) { if (typeof str !=…
-2
votes
1 answer

Why do arrays coerce in a specific way?

I'm struggling to understand why this examples below end up with this kind of results. String([,,,]); // ',,' why? Number([8,8]); // NaN why? please explain with details if possible
Shaqe
  • 5
  • 1
-4
votes
3 answers

Filter function with ternary

This was bothering me for hours...and I don't understand yet why. I have an array of of objects. Is my syntax bad for the ternary?... This is in React if that matters. The array is something like below [{id:1, name:'steve'}, {id:2, name:'john'}]…
born2gamble
  • 197
  • 7
  • 17
1 2 3
26
27