Search Results

Search found 977 results on 40 pages for 'operators'.

Page 7/40 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Ternary Operators in JavaScript Without an "Else"

    - by Oscar Godson
    I've been using them forever, and I love them. To me they see cleaner and i can scan faster, but ever since I've been using them i've always had to put null in the else conditions that don't have anything. Is there anyway around it? E.g. condition ? x=true : null ; basically, is there a way to do: condition ? x=true; Now it shows up as a syntax error...

    Read the article

  • Operators vs Functions in C/C++

    - by user356106
    Someone recently asked me the difference between a C++ standard operator (e.g. new,delete,sizeof) and function (e.g. tan,delete, malloc). By "standard" I mean those provided by default by the compiler suite, and not user defined. Below were the answers I gave, though neither seemed satisfactory. (1) An operator doesn't need any headers to be included to use it : E.g. you can have a call to new without including any headers. However, a function (say free() ) does need headers included, compulsorily. (2) An operator is defined as such (ie as a class operator) somewhere in the standard headers. A function isn't. Can you critique these answers and give me a better idea of the difference?

    Read the article

  • LinqToSql Sub Entiity Multiple And Operators

    - by halit
    Hi I have an Array of Featureset Id , My Vehicles table has got sub table as FeatureSets I wrote Sql Query Like SELECT [t0].[ID] FROM [dbo].[SearchResultView] AS [t0] Join [dbo].[VehicleFeatureSet] AS [t1] on t0.ID = t1.VehicleID where t1.FeatureSetID = 1 and t1.FeatureSetID= 2 and t1.FeatureSetID= 3 I tried. But I Couldn't var features = Request.QueryString["FeatureSets"].Split(',').ToList().ConvertAll(new Converter<string, int>(StrinToint)); IQueryable<SearchResultView> result = db.SearchResultViews.Where(m => m.Active == true); foreach (var featuree in features) { result = result.Where(m => m.VehicleFeatureSets.Any(c => c.FeatureSetID == featuree)); } How Can I write this LINQ Query

    Read the article

  • Identity operators in Swift

    - by Tao
    If a is identical to c, b is identical to c, why a is not identical to b? var a = [1, 2, 3] var b = a var c = a[0...2] a === c // true b === c // true a === b // false If a, b, c are constants: let a = [1, 2, 3] let b = a let c = a[0...2] a === c // true b === c // true a === b // true

    Read the article

  • DWORD to bytes using bitwise shift operators

    - by Dave18
    I can't get it to work correctly. #include <windows.h> int main() { DWORD i = 6521; BYTE first = i >> 32; BYTE second = i >> 24; BYTE third = i >> 16; BYTE fourth = i >> 8; i = (((DWORD)fourth) << 24) | (((DWORD)third) << 16) | (((DWORD)second) << 8) | first; }

    Read the article

  • Using enum values to represent binary operators (or functions)

    - by Bears will eat you
    I'm looking for an elegant way to use values in a Java enum to represent operations or functions. My guess is, since this is Java, there just isn't going to be a nice way to do it, but here goes anyway. My enum looks something like this: public enum Operator { LT, LTEQ, EQEQ, GT, GTEQ, NEQ; ... } where LT means < (less than), LTEQ means <= (less than or equal to), etc - you get the idea. Now I want to actually use these enum values to apply an operator. I know I could do this just using a whole bunch of if-statements, but that's the ugly, OO way, e.g.: int a = ..., b = ...; Operator foo = ...; // one of the enum values if (foo == Operator.LT) { return a < b; } else if (foo == Operator.LTEQ) { return a <= b; } else if ... // etc What I'd like to be able to do is cut out this structure and use some sort of first-class function or even polymorphism, but I'm not really sure how. Something like: int a = ..., b = ...; Operator foo = ...; return foo.apply(a, b); or even int a = ..., b = ...; Operator foo = ...; return a foo.convertToOperator() b; But as far as I've seen, I don't think it's possible to return an operator or function (at least, not without using some 3rd-party library). Any suggestions?

    Read the article

  • Evaluation of (de)reference operators

    - by Micha
    I have an (uncommented...) source file which I'm trying to understand. static const Map *gCurMap; static std::vector<Map> mapVec; then auto e = mapVec.end(); auto i = mapVec.begin(); while(i!=e) { // ... const Map *map = gCurMap = &(*(i++)); // ... } I don't understand what &(*(i++)) does. It does not compile when just using i++, but to me it looks the same, because I'm "incrementing" i, then I'm requesting the value at the given address and then I'm requesting the address of this value?!

    Read the article

  • Ternary operators in C#

    - by pm_2
    With the ternary operator, it is possible to do something like the following (assuming Func1() and Func2() return an int: int x = (x == y) ? Func1() : Func2(); However, is there any way to do the same thing, without returning a value? For example, something like (assuming Func1() and Func2() return void): (x == y) ? Func1() : Func2(); I realise this could be accomplished using an if statement, I just wondered if there was a way to do it like this.

    Read the article

  • how to refer to the current struct in an overloaded operator?

    - by genesys
    Hi! I have a struct for which i want to define a relative order by defining < , , <= and = operators. actually in my order there won't be any equality, so if one struct is not smaller than another, it's automatically larger. I defined the first operator like this: struct MyStruct{ ... ... bool operator < (const MyStruct &b) const {return (somefancycomputation);} }; now i'd like to define the other operators based on this operator, such that <= will return the same as < and the other two will simply return the oposite. so for example for the operator i'd like to write something like bool operator > (const MyStruct &b) const {return !(self<b);} but i don't know how to refere to this 'self' since i can refere only to the fields inside the current struct. whole is in C++ hope my question was understandable :) thank you for the help!

    Read the article

  • Java operator precedence guidelines

    - by trashgod
    Misunderstanding Java operator precedence is a source of frequently asked questions and subtle errors. I was intrigued to learn that even the Java Language Specification says, "It is recommended that code not rely crucially on this specification." JLS §15.7 Preferring clear to clever, are there any useful guidelines in this area? Here are a number of resources on the topic: JLS Operators JLS Precedence Java Glossary Princeton Sun Tutorial University of West Florida Usenet discussion Additions or corrections welcome.

    Read the article

  • How to use ternary operator instead of if-else in PHP

    - by Mac Taylor
    hey guys i need to shorten or better to say ., harden my codes this is my original code : if ($type = "recent") { $OrderType = "sid DESC"; }elseif ($type = "pop"){ $OrderType = "counter DESC"; }else { $OrderType = "RAND()"; } now how can i use markers like this : $OrderType = ($type = "recent") ? "sid DESC" : "counter DESC" ; i tried but i didnt know how to write elseif in operators

    Read the article

  • Perl ||= operator for PHP and Javascript

    - by zaf
    Just been re-introduced to the Perl '||=' operator from the classic Orcish Maneuver example: keys my %or_cache = @in; @out = sort { ($or_cache{$a} ||= KEY($a)) cmp ($or_cache{$b} ||= KEY($b)) } @in; Is this operator available in PHP and Javascript? And if not, do these two languages allow user defined operators?

    Read the article

  • 'AND' vs '&&' as operator

    - by ts
    Actually, i am facing a codebase where developpers decided to use 'AND' and 'OR' instead of '&&' and '||'. I know that there is difference in operators precedence (&& goes before 'and'), but with given framework (prestashop to be precise) is clearly not a reason. So, my question: which version are you using? Is 'and' more readable than '&&'? || there is ~ difference?

    Read the article

  • Are +=, |=, &= etc atomic?

    - by SF.
    Are the "modify" operators like +=, |=, &= etc atomic? I know ++ is atomic (if you perform x++; in two different threads "simultaneously", you will always end up with x increased by 2, as opposed to x=x+1 with optimization switched off.) What I wonder is whether variable |= constant, and the likes are thread-safe or do I have to protect them with a mutex? (...or is it CPU-dependent? In this case, how is it on ARM?)

    Read the article

  • In what situation should the built-in 'operator' module be used in python?

    - by apphacker
    I'm speaking of this module: http://docs.python.org/library/operator.html From the article: The operator module exports a set of functions implemented in C corresponding to the intrinsic operators of Python. For example, operator.add(x, y) is equivalent to the expression x+y. The function names are those used for special class methods; variants without leading and trailing __ are also provided for convenience. I'm not sure I understand the benefit or purpose of this module.

    Read the article

  • C++ and,or,not,xor keywords [closed]

    - by uray
    Possible Duplicate: The written versions of the logical operators. I notice that C++ define keyword and, or, not, xor, and_eq, or_eq, not_eq and xor_eq as an alternative to &&, ||, !, ^, &=, |=, != and |=. and they're rarely used! What's wrong? Are they not portable?

    Read the article

  • what is this operator called and what is it used for <=>

    - by Scott
    I recently came across this magical operator when digging into Groovy: <= Groovy has really made me happy with elvis operators ?. and ?: which I use constantly now and very much wish were in Java. With this new operator, I have only found this reference. It seems to make comparators much easier. My question is how does it handle null values and how does it compare non Comparable object. Does this operator have a name, I couldn't find it Googling.

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >