Search Results

Search found 5279 results on 212 pages for 'optional arguments'.

Page 10/212 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • What happens to C# 4 optional parameters when compiling against 3.5?

    - by Bertrand Le Roy
    Here’s a method declaration that uses optional parameters: public Path Copy( Path destination, bool overwrite = false, bool recursive = false) Something you may not know is that Visual Studio 2010 will let you compile this against .NET 3.5, with no error or warning. You may be wondering (as I was) how it does that. Well, it takes the easy and rather obvious way of not trying to be too smart and just ignores the optional parameters. So if you’re compiling against 3.5 from Visual Studio 2010, the above code is equivalent to: public Path Copy( Path destination, bool overwrite, bool recursive) The parameters are not optional (no such thing in C# 3), and no overload gets magically created for you. If you’re building a library that is going to have both 3.5 and 4.0 versions, and you want 3.5 users to have reasonable overloads of your methods, you’ll have to provide those yourself, which means that providing a version with optional parameters for the benefit of 4.0 users is not going to provide that much value, except for the ability to provide named parameters out of order. I guess that’s not so bad… Providing all of the following overloads will compile against both 3.5 and 4.0: public Path Copy(Path destination)public Path Copy(Path destination, bool overwrite)public Path Copy( Path destination, bool overwrite = false, bool recursive = false)

    Read the article

  • C# regex. Optional match after string

    - by Oskar Kjellin
    I have an input like this test1.test2.part01 which I want to strip away to test1.test2. The only thing i know is that it will end with partxx and probably a dot before the partxx. However, it will not always be a apart. Another example of input might be testas1.tlp2.asd3.part10 which ofcourse should be stripped to testas1.tlp2.asd3. I've made all that, no problem. The problem is the dot at the end before partxx. My regex at the moment is: (.*).?part\d{1,2} But it will include the dot in the group. I do not want the dot to be in the group. The below works as I want it, given that the dot exists, but it will not always be there. (.*).part\d{1,2} How can I exclude the optional dot from the group?

    Read the article

  • Java Prepared Statement arguments!

    - by Epitaph
    I am planning to replace repeatedly executed Statement objects with PreparedStatement objects to improve performance. I am using arguments like the MySQL function now(), and string variables. Most of the PreparedStatement queries I have seen contained constant values (like 10, and strings like "New York") as arguments used for the "?" in the queries. How would I go about using functions like now(), and variables as arguments? Is it necessary to use the "?"s in the queries instead of actual values? I am quite confounded.

    Read the article

  • Bison: Optional tokens in a single rule.

    - by Simone Margaritelli
    Hi there .. i'm using GNU Bison 2.4.2 to write a grammar for a new language i'm working on and i have a question. When i specify a rule, let's say : statement : T_CLASS T_IDENT '{' T_CLASS_MEMBERS '}' { // create a node for the statement ... } If i have a variation on the rule, for instance statement : T_CLASS T_IDENT T_EXTENDS T_IDENT_LIST '{' T_CLASS_MEMBERS '}' { // create a node for the statement ... } Where (from flex scanner rules) : "class" return T_CLASS; "extends" return T_EXTENDS; [a-zA-Z\_][a-zA-Z0-9\_]* return T_IDENT; (and T_IDENT_LIST is a rule for comma separated identifiers). Is there any way to specify all of this only in one rule, setting somehow the "T_EXTENDS T_IDENT_LIST" as optional? I've already tried with T_CLASS T_IDENT (T_EXTENDS T_IDENT_LIST)? '{' T_CLASS_MEMBERS '}' { // create a node for the statement ... } But Bison gave me an error. Thanks

    Read the article

  • Manage Foreign key and Drop downlist for optional field in .NET

    - by Brij
    What is the best way to handle following situation? A dropdown(for master table) is optional in a particular form. But, In database table the field is constrained with foreign key. If user don't select from dropdown then It creates problem because of foreign key. One solution is to create default option in master table and use it in case of blank selection. but in dropdown, we need to handle this to show on top. Is it perfect solution? Is there any other optimized solution for this? Thanks

    Read the article

  • Custom UITableviewcell shows "fatal error: Can't unwrap Optional.None" issue in swift

    - by user1656286
    I need to load a custom cell in a UITableView. I created a custom subclass of UITableViewCell named "CustomTableViewCell". I have added a UITabelViewCell to the tableview (using drag and drop) as shown in figure. Then in file inspector I set the class of that UITabelViewCell to be "CustomTableViewCell". Here is my code: class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource { @IBOutlet var tableView : UITableView var items = String[]() override func viewDidLoad() { super.viewDidLoad() items = ["Hi","Hello","How"] self.tableView.registerClass(CustomTableViewCell.self, forCellReuseIdentifier: "CusTomCell") // Do any additional setup after loading the view, typically from a nib. } func tableView(tableView: UITableView!, numberOfRowsInSection section: Int) -> Int{ return items.count } func tableView(tableView: UITableView!, cellForRowAtIndexPath indexPath: NSIndexPath!) -> UITableViewCell!{ var cell:CustomTableViewCell = self.tableView.dequeueReusableCellWithIdentifier("CusTomCell") as CustomTableViewCell cell.labelTitle.text = items[indexPath.row] return cell; } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } When I run my code, I get the following error: "fatal error: Can't unwrap Optional.None" as seen in the image.

    Read the article

  • jQuery plugin options: required, optional, inaccessible

    - by Trevor Hartman
    I'm curious how to specify options to a jQuery plugin in a way that some are required, some are optionally overridden, and some can't be touched. I started off with the usual: jQuery.fn.plugin = function (options){ var defaults = { username: "", posts:10, api: "http://myapi.com" } var settings = jQuery.extend({}, defaults, options); } Let's say I want username to be required, posts is optional (defaults to 10) and you (you being the user of the plugin) can't change api, even if they try. Ideally, they'd all still be in the same data structure instead of being split into separate objects. Ideas?

    Read the article

  • ANTLR, optional ';' in JavaScript

    - by vava
    I'm just playing with ANTLR and decided to try parsing JavaScript with it. But I hit the wall in dealing with optional ';' in it, where statement end is marked by newline instead. Can it be done in some straightforward way? Just a simple grammar example that doesn't work grammar optional_newline; def : statements ; statements : statement (statement)* ; statement : expression (';' | '\n') ; expression : ID | INT | 'var' ID '=' INT ; ID : ('a'..'z'|'A'..'Z'|'_') ('a'..'z'|'A'..'Z'|'0'..'9'|'_')* ; INT : '0'..'9'+ ; WS : ( ' ' | '\t' | '\r' | '\n') {$channel=HIDDEN;} ; and I want to be able to parse this (which can be parsed by JavaScript parsers) var i = 10 10; PS: I don't want to put WS in parser rules, I would be much happier if lexer just get rid of those.

    Read the article

  • How to assign optional attribute of NSManagedObject in a NSManagedObjectModel having Three NSManaged

    - by Kundan
    I am using coredata framework. In my NSManagedObjectModel i am using three entities that are Class, Student and Score where class and student have one-to-many & inverse relationship and Student and Score have also inverse but one-one relationship. Score entity has all optional attributes and having default '0' decimalVaue, which is not assigned at the time new Student is added. But later i want to assign them score individually and also to particular attribute not all of score attributes in a go. I am able to create and add Students to particular Class but dont have any idea how to call particular student and assign them score. For example I want to assign Score'attribute "dribbling" [there are many attributes like "tackling"] a decimal value to Student "David" of Class "Soccer" ,how i can do that? Thanks in advance for any suggestion.

    Read the article

  • optional search parameters in sql query and rows with null values

    - by glenn.danthi
    Ok here is my problem : Before i start the description, let me to tell you that I have googled up a lot and I am posting this question for a good optimal solution :) i am building a rest service on WCF to get userProfiles... the user can filter userProfiles by giving something like userProfiles?location=London now i have the following method GetUserProfiles(string firstname, string lastname, string age, string location) the sql query string i built is: select firstname, lastname, .... from profiles where (firstName like '%{firstname}%') AND (lastName like '%{lastName}%') ....and so on with all variables being replaced by string formatter. Problem with this is that it filters any row having firstname, lastname, age or location having a null value.... doing something like (firstName like '%{firstName}%' OR firstName IS NULL) would be tedious and the statement would become unmaintanable! (in this example there are only 4 arguments, but in my actual method there are 10) What would be the best solution for this?....How is this situation usually handled? Database used : MySql

    Read the article

  • Scala: Matching optional Regular Expression groups

    - by Brian Heylin
    I'm trying to match on an option group in Scala 2.8 (beta 1) with the following code: import scala.xml._ val StatementPattern = """([\w\.]+)\s*:\s*([+-])?(\d+)""".r def buildProperty(input: String): Node = input match { case StatementPattern(name, value) => <propertyWithoutSign /> case StatementPattern(name, sign, value) => <propertyWithSign /> } val withSign = "property.name: +10" val withoutSign = "property.name: 10" buildProperty(withSign) // <propertyWithSign></propertyWithSign> buildProperty(withoutSign) // <propertyWithSign></propertyWithSign> But this is not working. What is the correct way to match optional regex groups?

    Read the article

  • How to later assign value to optional attribute of NSManagedObject in a NSManagedObjectModel having

    - by Kundan
    I am using coredata framework. In my NSManagedObjectModel i am using three entities that are Class, Student and Score where class and student have one-to-many & inverse relationship and Student and Score have also inverse but one-one relationship. Score entity has all optional attributes and having default '0' decimalVaue, which is not assigned at the time new Student is added. But later i want to assign them score individually and also to particular attribute not all of score attributes in a go. I am able to create and add Students to particular Class but dont have any idea how to call particular student and assign them score. For example I want to assign Score'attribute "dribbling" [there are many attributes like "tackling"] a decimal value to Student "David" of Class "Soccer" ,how i can do that? Thanks in advance for any suggestion.

    Read the article

  • Flash AS3: automate property assignment to new instance from arguments in constructor

    - by matt lohkamp
    I like finding out about tricky new ways to do things. Let's say you've got a class with a property that gets set to the value of an argument in the constructor, like so: package{ public class SomeClass{ private var someProperty:*; public function SomeClass(_someProperty:*):void{ someProperty = _someProperty; } } } That's not exactly a hassle. But imagine you've got... I don't know, five properties. Ten properties, maybe. Rather then writing out each individual assignment, line by line, isn't there a way to loop through the constructor's arguments and set the value of each corresponding property on the new instance accordingly? I don't think that the ...rest or arguments objects will work, since they only keep an enumerated list of the arguments, not the argument names - I'm thinking something like this would be better: for(var propertyName:String in argsAsAssocArray){this[propertyName] = argsAsAssocArray[propertyName];} ... does something like this exist?

    Read the article

  • How to handle Foreign key for optional field in .NET

    - by brz dot net
    What is the best way to handle following situation? A dropdown(for master table) is optional in a particular form. But, In database table the field is constrained with foreign key. If user don't select from dropdown then It creates problem because of foreign key. One solution is to create default option in master table and use it in case of blank selection. but in dropdown, we need to handle this to show on top. Is it perfect solution? Is there any other optimized solution for this? Thanks

    Read the article

  • Bitfield mask/operations with optional items

    - by user1560249
    I'm trying to find a way to handle several bitfield cases that include optional, required, and not allowed positions. yy?nnn?y 11000001 ?yyy?nnn 01110000 nn?yyy?n 00011100 ?nnn?yyy 00000111 In these four cases, the ? indicates that the bit can be either 1 or 0 while y indicates a 1 is required and n indicates that a 0 is required. The bits to the left/right of the required bits can be anything and the remaining bits must be 0. Is there a masking method I can use to test if an input bit set satisfies one of these cases?

    Read the article

  • Django - how to make ImageField/FileField optional?

    - by ilya
    class Product(models.Model): ... image = models.ImageField(upload_to = generate_filename, blank = True) When I use ImageField (blank=True) and do not select image into admin form, exception occures. In django code you can see this: class FieldFile(File): .... def _require_file(self): if not self: raise ValueError("The '%s' attribute has no file associated with it." % self.field.name) def _get_file(self): self._require_file() ... Django trac has ticket #13327 about this problem, but seems it can't be fixed soon. How to make these field optional?

    Read the article

  • Optional URL fragment in Codeigniter?

    - by DA
    This is maybe a simple syntax question or possibly a best-practices question in terms of codeigniter. I should start by saying I'm not a PHP or Codeigniter person so trying to get up to speed on helping on a project. I've found the CI documentation fairly good. The one question I can't find an answer to is how to make part of a URL optional. An example the CI documentation uses is this: example.com/index.php/products/shoes/sandals/123 and then the function used to parse the URI: function shoes($sandals, $id) For my example, I'd like to be able to modify the URL as such: example.com/index.php/products/shoes/all So, if no ID is passed, it's just ignored. Can that be done? Should that be done? A second question unrelated to my problem but pertaining to the example above, why would the variable $sandals be used as in the example, the value is 'sandals'? Shouldn't that variable be something like $shoetype?

    Read the article

  • Obtaining command line arguments in a QT console app

    - by morpheous
    The following snippet is from a little console app I wrote using the QT framework. Currently, it does not receive the arguments passed at the CLI. Can anyone spot what I may be doing wrong? int main(int argc, char *argv[]) { //Q_INIT_RESOURCE(application); try { QApplication the_app(argc, argv); utility::option_values ov; QStringList cmdline_args = QCoreApplication::arguments(); //attempt to parse arguments here, but cmdline_args is an empty list :( ov.parse_options(cmdline_args); // Code continues ... } } catch (utility::invalid_option&) { return 1; } return 0; } I am debugging using QtCreator 1.3

    Read the article

  • Rails, making certain multiparameter attributes optional?

    - by Joseph Silvashy
    Is there a method already part of Rails for making certain parameters option when part of a multiparameter attribute, for example say I'm prompting a user for their birthday, when saved the has may look like this: "birthday(2i)"=>"8", "birthday(3i)"=>"17", "birthday(1i)"=>"1980"}, ... But the issue arises when say I want to allow the user to just provide their month and day, making the year optional, how would this work being a datetime object, I'm assuming you can't do this as a date object... but any ideas would be helpful. Happy new year.

    Read the article

  • how to pass variable arguments from one function to other in tcl

    - by vaichidrewar
    I want to pass variable arguments obtained in one function to other function but I am not able to do so. Function gets even number of variable arguments and then it has to be converted in array. Below is the example. Procedure abc1 gets two arguments (k k) and not form abc1 procedure these have to be passed to proc abc where list to array conversion it to be done. List to array conversion works in proc1 i.e. abc1 but not in second proc i.e. abc Error obtained is given below proc abc {args} { puts "$args" array set arg $args } proc abc1 {args} { puts "$args" array set arg $args set l2 [array get arg] abc $l2 } abc1 k k abc k k Output: k k {k k} list must have an even number of elements while executing "array set arg $l1" (procedure "abc" line 8) invoked from within "abc $l2" (procedure "abc1" line 5) invoked from within "abc1 k k" (file "vfunction.tcl" line 18)

    Read the article

  • End marker for command line arguments

    - by rwallace
    I'm writing a program which takes filenames and options on the command line in the usual way, and also can be directed to read arguments from a file. I'm implementing the semi-standard -- to turn off special treatment of subsequent arguments, and # as comment marker. I also want to implement a marker for 'disregard all arguments from here on', i.e. an end marker. Is there a common/semi-standard way to indicate this? Or, what way would people find least surprising?

    Read the article

  • Rails: Modeling an optional relation in ActiveRecord

    - by Hassinus
    I would like to map a relation between two Rails models, where one side can be optionnal. Let's me be more precise... I have two models: Profile that stores user profile information (name, age,...) and User model that stores user access to the application (email, password,...). To give you more information, User model is handled by Devise gem for signup/signin. Here is the scenario of my app: 1/ When a user register, a new row is created in User table and there is an equivalent in Profile table. This leads to the following script: class User < ActiveRecord::Base belongs_to :profile end 2/ A user can create it's profile without registering (kind of public profile with public information), so a row in Profile doesn't have necessarily a User row equivalent (here is the optional relation, the 0..1 relation in UML). Question: What is the corresponding script to put in class Profile < AR::Base to map optionally with User? Thanks in advance.

    Read the article

  • git post-receive hook doesn't get promised arguments

    - by Zimno
    From the post-receive file: # This script is run after receive-pack has accepted a pack and the # repository has been updated. It is passed arguments in through stdin # in the form # <oldrev> <newrev> <refname> # For example: # aa453216d1b3e49e7f6f98441fa56946ddcd6a20 68f7abf4e6f922807889f52bc043ecd31b79f814 refs/heads/master # But when I test it with echo "$1 $2 $3", I get a blank line only. Does any-one know why?

    Read the article

  • Chrome command line arguments w/ url?

    - by John Isaacks
    when launching chrome from the windows command line I can pass arguments like so: ...>chrome.exe -incognito I can also pass a URL to open ...>chrome.exe google.com Each work fine on their own but I can't get them to work together. What I want is to launch it with a url, and open in its OWN tab, and hide the url, buttons, etc. like a utility window but I do want it resizable.

    Read the article

  • MSI Arguments for installation

    - by Alex Zmaczynski
    Does anyone know where to find various arguments for msi's, such as installing/running as administrator, or restart after installation. I am trying to push out an msi update through group policy, but after testing the msi I found out that it needs to be run as administrator to install, and that for it to begin working fully the computer needs to be rebooted. Any help would be greatly appreciated. Thank you.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >