Search Results

Search found 11178 results on 448 pages for 'syntax checking'.

Page 58/448 | < Previous Page | 54 55 56 57 58 59 60 61 62 63 64 65  | Next Page >

  • Can any body help to split php source code

    - by joe-on-wp
    hi, can any body help me on separating this example of data that i need to parse and seperate text just like PHPDoc. It is PHP source code. The example string : function one_to_tree() { //bla bla bla return FALSE; } function two_to_tree() { //bla bla bla return FALSE; } function three_to_tree() { if ($sample){ //bla bla bla } return FALSE; } can anybody help me how to seperate above string based on "function" word and create and array. Thank you

    Read the article

  • problems with chili source code highlighter (mysql)

    - by jason
    I am using Chili source code highlighter it works fine with php source using php as the class. But when i change it to mysql it doesnt highlight any SQL code i also tried sql as the classname, i double checked the recipes' and there is a mysql recipes in there. ... What could i be doing wrong? <pre><code id="code" class="php"></code></pre>

    Read the article

  • ruby send vs __send__

    - by jaydel
    I understand the concept of some_instance.send but I'm trying to figure out why you can call this both ways? The Ruby Koans imply that there is some reason beyond providing lots of different ways to do the same thing and I'm wrestling with figuring this out. Here are the two examples of usage more concretely class Foo def bar? true end end foo = Foo.new foo.send(:bar?) foo.send(:bar?) Anyone have any idea about this? thanks in advance!

    Read the article

  • Retrieving data from enumerated JSON sub arrays in Javascript without getJSON

    - by Archie Ec
    I'm new to JSON and ajax, but i'm trying to access data in an array where the items are enumerated in a sub array within another sub array. So, I can access without issues data.items[0].details.specs.name data.items[0].details.specs.id etc But I run into problems with I try to access something like data.items[0].details.specs[1].name data.items[0].details.specs[1].id data.items[0].details.specs[2].name data.items[0].details.specs[2].id etc Can anyone point me in the right direction on how to access this second aspect? Thanks.

    Read the article

  • Passing a comparator syntax help in Java

    - by Crystal
    I've tried this a couple ways, the first is have a class that implements comparator at the bottom of the following code. When I try to pass the comparat in sortListByLastName, I get a constructor not found error and I am not sure why import java.util.*; public class OrganizeThis implements WhoDoneIt { /** Add a person to the organizer @param p A person object */ public void add(Person p) { staff.put(p.getEmail(), p); //System.out.println("Person " + p + "added"); } /** * Remove a Person from the organizer. * * @param email The email of the person to be removed. */ public void remove(String email) { staff.remove(email); } /** * Remove all contacts from the organizer. * */ public void empty() { staff.clear(); } /** * Find the person stored in the organizer with the email address. * Note, each person will have a unique email address. * * @param email The person email address you are looking for. * */ public Person findByEmail(String email) { Person aPerson = staff.get(email); return aPerson; } /** * Find all persons stored in the organizer with the same last name. * Note, there can be multiple persons with the same last name. * * @param lastName The last name of the persons your are looking for. * */ public Person[] find(String lastName) { ArrayList<Person> names = new ArrayList<Person>(); for (Person s : staff.values()) { if (s.getLastName() == lastName) { names.add(s); } } // Convert ArrayList back to Array Person nameArray[] = new Person[names.size()]; names.toArray(nameArray); return nameArray; } /** * Return all the contact from the orgnizer in * an array sorted by last name. * * @return An array of Person objects. * */ public Person[] getSortedListByLastName() { PersonLastNameComparator comp = new PersonLastNameComparator(); Map<String, Person> sorted = new TreeMap<String, Person>(comp); ArrayList<Person> sortedArrayList = new ArrayList<Person>(); for (Person s: sorted.values()) { sortedArrayList.add(s); } Person sortedArray[] = new Person[sortedArrayList.size()]; sortedArrayList.toArray(sortedArray); return sortedArray; } private Map<String, Person> staff = new HashMap<String, Person>(); public static void main(String[] args) { OrganizeThis testObj = new OrganizeThis(); Person person1 = new Person("J", "W", "111-222-3333", "[email protected]"); Person person2 = new Person("K", "W", "345-678-9999", "[email protected]"); Person person3 = new Person("Phoebe", "Wang", "322-111-3333", "[email protected]"); Person person4 = new Person("Nermal", "Johnson", "322-342-5555", "[email protected]"); Person person5 = new Person("Apple", "Banana", "123-456-1111", "[email protected]"); testObj.add(person1); testObj.add(person2); testObj.add(person3); testObj.add(person4); testObj.add(person5); System.out.println(testObj.findByEmail("[email protected]")); System.out.println("------------" + '\n'); Person a[] = testObj.find("W"); for (Person p : a) System.out.println(p); System.out.println("------------" + '\n'); a = testObj.find("W"); for (Person p : a) System.out.println(p); System.out.println("SORTED" + '\n'); a = testObj.getSortedListByLastName(); for (Person b : a) { System.out.println(b); } System.out.println(testObj.getAuthor()); } } class PersonLastNameComparator implements Comparator<Person> { public int compare(Person a, Person b) { return a.getLastName().compareTo(b.getLastName()); } } And then when I tried doing it by creating an anonymous inner class, I also get a constructor TreeMap cannot find symbol error. Any thoughts? inner class method: public Person[] getSortedListByLastName() { //PersonLastNameComparator comp = new PersonLastNameComparator(); Map<String, Person> sorted = new TreeMap<String, Person>(new Comparator<Person>() { public int compare(Person a, Person b) { return a.getLastName().compareTo(b.getLastName()); } }); ArrayList<Person> sortedArrayList = new ArrayList<Person>(); for (Person s: sorted.values()) { sortedArrayList.add(s); } Person sortedArray[] = new Person[sortedArrayList.size()]; sortedArrayList.toArray(sortedArray); return sortedArray; }

    Read the article

  • What does the '&' operator do in C++?

    - by rascher
    n00b question. I am a C guy and I'm trying to understand some C++ code. I have the following function declaration: int foo(const string &myname) { cout << "called foo for: " << myname << endl; return 0; } How does the function signature differ from the equivalent C: int foo(const char *myname) Is there a difference between using string *myname vs string &myname? What is the difference between & in C++ and * in C to indicate pointers? Similarly: const string &GetMethodName() { ... } What is the & doing here? Is there some website that explains how & is used differently in C vs C++?

    Read the article

  • postgres counting one record twice if it meets certain criteria

    - by Dashiell0415
    I thought that the query below would naturally do what I explain, but apparently not... My table looks like this: id | name | g | partner | g2 1 | John | M | Sam | M 2 | Devon | M | Mike | M 3 | Kurt | M | Susan | F 4 | Stacy | F | Bob | M 5 | Rosa | F | Rita | F I'm trying to get the id where either the g or g2 value equals 'M'... But, a record where both the g and g2 values are 'M' should return two lines, not 1. So, in the above sample data, I'm trying to return: $q = pg_query("SELECT id FROM mytable WHERE ( g = 'M' OR g2 = 'M' )"); 1 1 2 2 3 4 But, it always returns: 1 2 3 4

    Read the article

  • "Socket operation on non-socket" error due to strange syntax

    - by Robert S. Barnes
    I ran across the error Socket operation on non-socket in some of my networking code when calling connect and spent a lot of time trying to figure out what was causing it. I finally figured out that the following line of code was causing the problem: if ((sockfd = socket( ai->ai_family, ai->ai_socktype, ai->ai_protocol) < 0)) { See the problem? Here's what the line should look like: if ((sockfd = socket( ai->ai_family, ai->ai_socktype, ai->ai_protocol)) < 0) { What I don't understand is why the first, incorrect line doesn't produce a warning. To put it another way, shouldn't the general form: if ( foo = bar() < baz ) do_something(); look odd to the compiler, especially running with g++ -Wall -Wextra? If not, shouldn't it at least show up as "bad style" to cppcheck, which I'm also running as part of my compile?

    Read the article

  • What is the form_for syntax for nested resources?

    - by Kris
    I am trying to create a form for a nested resource. Here is my route: map.resources :websites do |website| website.resources :domains end Here are my attempts and the errors: <% form_for(@domain, :url => website_domains_path(@website)) do | form | %> <%= form.text_field :name %> # ArgumentError: wrong number of arguments (1 for 0) # form_helper.rb:290:in 'respond_to?' # form_helper.rb:290:in 'apply_form_for_options!' # form_helper.rb:277:in 'form_for' <% form_for([@website, @domain]) do | form | %> <%= form.text_field :name %> # ArgumentError: wrong number of arguments (1 for 0) # form_helper.rb:290:in 'respond_to?' # form_helper.rb:290:in 'apply_form_for_options!' # form_helper.rb:277:in 'form_for' <% form_for(:domain, @domain, :url => website_domains_path(@website)) do | form | %> <%= form.text_field :name %> # ArgumentError: wrong number of arguments (1 for 0) # wrapper.rb:14:in 'respond_to?' # wrapper.rb:14:in 'wrap' # active_record_helper.rb:174:in 'error_messages_for' <% form_for(:domain, [@website, @domain]) do | form | %> <%= form.text_field :name %> # UndefinedMethodError 'name' for #<Array:0x40fa498> I have confirmed both @website and @domain contain instances of the correct class. The routes also generate correctly is used like this for example, so I dont think their is an issue with the route or url helpers. <%= website_domains_path(1) %> <%= website_data_source_path(1, 1) %> Rails 2.3.5

    Read the article

  • Why does one of these statements compile in Scala but not the other?

    - by Jeff
    (Note: I'm using Scala 2.7.7 here, not 2.8). I'm doing something pretty simple -- creating a map based on the values in a simple, 2-column CSV file -- and I've completed it easily enough, but I'm perplexed at why my first attempt didn't compile. Here's the code: // Returns Iterator[String] private def getLines = Source.fromFile(csvFilePath).getLines // This doesn't compile: def mapping: Map[String,String] = { Map(getLines map { line: String => val pairArr = line.split(",") pairArr(0) -> pairArr(1).trim() }.toList:_*) } // This DOES compile def mapping: Map[String,String] = { def strPair(line: String): (String,String) = { val pairArr = line.split(",") pairArr(0) -> pairArr(1).trim() } Map(getLines.map( strPair(_) ).toList:_*) } The compiler error is CsvReader.scala:16: error: value toList is not a member of (St ring) = (java.lang.String, java.lang.String) [scalac] possible cause: maybe a semicolon is missing before `value toList'? [scalac] }.toList:_*) [scalac] ^ [scalac] one error found So what gives? They seem like they should be equivalent to me, apart from the explicit function definition (vs. anonymous in the nonworking example) and () vs. {}. If I replace the curly braces with parentheses in the nonworking example, the error is "';' expected, but 'val' found." But if I remove the local variable definition and split the string twice AND use parens instead of curly braces, it compiles. Can someone explain this difference to me, preferably with a link to Scala docs explaining the difference between parens and curly braces when used to surround method arguments?

    Read the article

  • Python: needs more than 1 value to unpack

    - by Rosarch
    What am I doing wrong to get this error? replacements = {} replacements["**"] = ("<strong>", "</strong>") replacements["__"] = ("<em>", "</em>") replacements["--"] = ("<blink>", "</blink>") replacements["=="] = ("<marquee>", "</marquee>") replacements["@@"] = ("<code>", "</code>") for delimiter, (open_tag, close_tag) in replacements: # error here message = self.replaceFormatting(delimiter, message, open_tag, close_tag); The error: Traceback (most recent call last): File "", line 1, in for shit, (a, b) in replacements: ValueError: need more than 1 value to unpack All the values tuples have two values. Right?

    Read the article

  • In xpath why can I use greater-than symbol > but not less-than <

    - by runrunraygun
    Using c#3 compiled transforms the following seems to work just fine... <xsl:choose> <xsl:when test="$valA > $valB"> <xsl:value-of select="$maxUnder" /> </xsl:when> <xsl:when test="$valA &lt; $valC"> <xsl:value-of select="$maxOver" /> </xsl:when> </xsl:choose> However if i dare use a < in place of &lt; it gives an error... <xsl:choose> <xsl:when test="$valA > $valB"> <xsl:value-of select="$maxUnder" /> </xsl:when> <xsl:when test="$valA < $valC"> <xsl:value-of select="$maxOver" /> </xsl:when> </xsl:choose> System.Xml.XmlException: '<', hexadecimal value 0x3C, is an invalid attribute character. So why is > ok and not < ?

    Read the article

  • Ruby: change each value in a hash with something like #collect for arrays?

    - by Adam Nonymous
    Hi! I'd like to replace each value in a hash with value.some_method. For example in a simple hash {"a" = "b", "c" = "d"} every value should be .upcase-d so it looks like {"a" = "B", "c" = "D"}. I tried #collect and #map but always just get arrays back. Is there an 'elegant' way to do this? Thanks in advance, Adam Nonymous UPDATE: Damn, I forgot: The hash is in an instance variable which should not be changed. I need a new hash with the changed values, but would prefer not to define that variable explicitly and then loop over the hash filling it. Something like new_hash = hash.magic {...} ;)

    Read the article

  • java - coding errors causing endless loop

    - by Daniel Key
    Im attempting to write a program that takes a population's birthrate and deathrate and loops the annual population until it either reaches 0 or doubles. My problem it that it continuously loops an endless amount of illegible numbers and i cant fix it. please help. //***************************************** //This program displays loop statements //Written by: Daniel Kellogg //Last Edited: 9/28/12 //**************************************** import java.util.Scanner; public class Hwk6 { public static void main (String[] args) { int currentYear, currentPopulation; double birthRate, deathRate; Scanner stdin = new Scanner(System.in); System.out.println("\nPopulation Estimator\n"); System.out.println("Enter Year"); currentYear = stdin.nextInt(); System.out.println("Enter Current Population"); currentPopulation = stdin.nextInt(); System.out.println("Enter Birthrate of Population"); birthRate = stdin.nextDouble(); System.out.println("Enter Deathrate of Population"); deathRate = stdin.nextDouble(); int counter = currentPopulation; System.out.println("Population: "); while (currentPopulation != -1) while (counter < currentPopulation * 2) { System.out.print(counter + " "); counter = counter + (int)(counter * birthRate - counter * deathRate); } System.exit(0); } }

    Read the article

  • Is Odersky serious with "bills !*&^%~ code!" ?

    - by stacker
    In his book programming in scala (Chapter 5 Section 5.9 Pg 93) Odersky mentioned this expression "bills !*&^%~ code! In the footnote on same page: "By now you should be able to figure out that given this code,the Scala compiler would invoke (bills.!*&^%~(code)).!()." That's a bit to cryptic for me, could someone explain what's going on here?

    Read the article

  • When to use or not use symbols in PHP

    - by brett
    I'm reading a PHP book where the author says that symbols should be avoided except when it's valid to use them. Very informative stuff, if he could only elaborate or give code examples but he doesn't. Can someone from the experienced PHP bunch give me an example of what these symbols are, and when it makes sense to use them or not. I'm looking for a code example that I can wrap my head around since I don't quite get it in plain English. Code is more plain English to me.

    Read the article

  • json object composition details

    - by Ethan
    in .json text, is the 'value' in a basic single pair object the title of a value type (e.g. [string, number, object]), or a value for a typed object (e.g. 2, or "dog", or Object3)? This is how http://www.json.org/ presents the information: "An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma)."

    Read the article

< Previous Page | 54 55 56 57 58 59 60 61 62 63 64 65  | Next Page >