Search Results

Search found 6186 results on 248 pages for 'syntax'.

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

  • PHP shorthand syntax

    - by alex
    I've just came across this on GitHub. ($config === NULL) and $config = Kohana::config('email'); Is that the equivalent of if ($config === NULL) { $config = Kohana::config('email'); } Is this commonplace? Would I expect other developers looking at my code if I used that first way to instantly know what it was doing?

    Read the article

  • Haskell Syntax: Parse Error On Input

    - by NuNu
    As part of a mini-haskell compiler that I'm writing, I have a function named app. What I want this function to do is take in these arguments epp (App e1 e2). The first step would be to evaluate e1 recursively (epp e1) and check if the output would be an error. If not then evaluate e2 and then call another function eppVals to evaluate the outputs of the calls on e1 and e2 which I defined as v1 and v2 respectively. epp (App e1 e2) | epp e1 /= Error = eppVals v1 v2 | otherwise = Error where v1 = epp e1 v2 = epp e2 <- parse error on input `=' Logically I believe what I have written so far works but I'm getting a parse error on input = where I stated above. Any idea why? My second try epp :: Exp -> Error Val epp (App e1 e2) = (eppVals v1 v2) where v1 = (epp e1) v2 = (epp e2) But now throws Couldn't match expected type Val with actual type Error Val

    Read the article

  • C# unusual inheritance syntax w/ generics

    - by anon
    I happened upon this in an NHibernate class definition: public class SQLiteConfiguration : PersistenceConfiguration<SQLiteConfiguration> So this class inherits from a base class that is parameterized by... the derived class?   My head just exploded. Can someone explain what this means and how this pattern is useful? (This is NOT an NHibernate-specific question, by the way.)

    Read the article

  • Rails newb syntax question

    - by Veep
    I'm in the console, looking at someone else's app. I come across the following: >> p.location => [#<Tag id: 2, name: "projects">] Why do I see this result, which seems to be the object name, and how do I access the actual attribute name, "projects"? >> p.location.name => "Tag" Thank you very much!

    Read the article

  • php syntax confusion accessing database result

    - by Babak
    I am trying to do the following: <?php foreach($sqlResult as $row): ?> <tr> <?php foreach($formdata['columns'] as $column): ?> <td><?php echo $row->$column['name']; ?></td> <?php endforeach; ?> </tr> <?php endforeach; ?> This does not work. $row is returned by my mysql query, it has the following : row-id, row-author, row-name and these work as they echo fine. $columns is the following array: 'columns' => array ( 1 => array ( 'name' => 'id' ), 2 => array ( 'name' => 'author' ), 3 => array ( 'name' => 'date' ), 4 => array ( 'name' => 'title' ) it also works fine as $column['name'] echoes id, author, date, title my question is how would it be possible for me to access the $row-method (is it a method?) by passing it a name from the array??

    Read the article

  • New/strange Java "try()" syntax?

    - by Ali
    While messing around with the custom formatting options in Eclipse, in one of the sample pieces of code, I say code as follows: /** * 'try-with-resources' */ class Example { void foo() { try (FileReader reader1 = new FileReader("file1"); FileReader reader2 = new FileReader("file2")) { } } } I've never seen try used like this and I've been coding in Java for 9 years! Does any one know why you would do this? What is a possible use-case / benefit of doing this? An other pieces of code I saw, I thought was a very useful shorthand so I'm sharing it here as well, it's pretty obvious what it does: /** * 'multi-catch' */ class Example { void foo() { try { } catch (IllegalArgumentException | NullPointerException | ClassCastException e) { e.printStackTrace(); } } }

    Read the article

  • Javascript Instance Variable Syntax (AJAX page refresh)

    - by Rosarch
    I'm having difficulty with Javascript instance variables. I'm trying to make an easy way to refresh the chat page, looking for new messages. The AJAX call supplies a mid, or the lowest message id to be returned. This allows the call to only ask for the most recent messages, instead of all of them. MessageRefresher.prototype._latest_mid; function MessageRefresher(latest_mid) { this._latest_mid = latest_mid; // it thinks `this` refers to the MessageRefresher object } MessageRefresher.prototype.refresh = function () { refreshMessages(this._latest_mid); // it thinks `this` refers to the window this._latest_mid++; } function refreshMessages(latest_mid) { $.getJSON('API/read_messages', { room_id: $.getUrlVar('key'), mid: latest_mid }, function (messages) { for (var i = 0; i < messages[0].length; i++) { var newChild = sprintf("<li>%s: %s</li>", messages[1][i], messages[0][i]); $("#messages").append(newChild); } }); var messageRefresher = new MessageRefresher(0); setInterval(messageRefresher.refresh, 1000); This results in all the messages being printed out, over and over again. I know it has other bugs, but the main issue I'm trying to work out right now is the use of the instance variable. Or is there another way I should be going about doing this?

    Read the article

  • Question about Transact SQL syntax

    - by Yousui
    Hi guys, The following code works like a charm: BEGIN TRY BEGIN TRANSACTION COMMIT TRANSACTION END TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK; DECLARE @ErrorMessage NVARCHAR(4000), @ErrorSeverity int; SELECT @ErrorMessage = ERROR_MESSAGE(), @ErrorSeverity = ERROR_SEVERITY(); RAISERROR(@ErrorMessage, @ErrorSeverity, 1); END CATCH But this code gives an error: BEGIN TRY BEGIN TRANSACTION COMMIT TRANSACTION END TRY BEGIN CATCH IF @@TRANCOUNT > 0 ROLLBACK; RAISERROR(ERROR_MESSAGE(), ERROR_SEVERITY(), 1); END CATCH Why?

    Read the article

  • better for-loop syntax for detecting empty sequences?

    - by Dmitry Beransky
    Hi, Is there a better way to write the following: row_counter = 0 for item in iterable_sequence: # do stuff with the item counter += 1 if not row_counter: # handle the empty-sequence-case Please keep in mind that I can't use len(iterable_sequence) because 1) not all sequences have known lengths; 2) in some cases calling len() may trigger loading of the sequence's items into memory (as the case would be with sql query results). The reason I ask is that I'm simply curious if there is a way to make above more concise and idiomatic. What I'm looking for is along the lines of: for item in sequence: #process item *else*: #handle the empty sequence case (assuming "else" here worked only on empty sequences, which I know it doesn't)

    Read the article

  • Why was this T-SQL Syntax never implemented?

    - by ChrisA
    Why did they never let us do this sort of thing: Create Proc RunParameterisedSelect @tableName varchar(100), @columnName varchar(100), @value varchar(100) as select * from @tableName where @columnName = @value You can use @value as a parameter, obviously, and you can achieve the whole thing with dynamic SQL, but creating it is invariably a pain. So why didn't they make it part of the language in some way, rather than forcing you to EXEC(@sql)?

    Read the article

  • Unfamiliar Javascript Syntax

    - by user1051643
    Long and short of the story is, whilst reading John Resig's blog (specifically http://ejohn.org/blog/javascript-trie-performance-analysis/) I came across a line which makes absolutely no sense to me whatsoever. Essentially it boils down to object = object[key] = something; (this can be found in the first code block of the article I've linked.) This has proven rather difficult to google, so if anyone can offer some insight / a good online resource for me to learn for myself, I'd much appreciate it.

    Read the article

  • .htaccess: RewriteCond syntax?

    - by Rosarch
    I'm using Drupal 6. Typically, when the user requests a URL for which Drupal has no response, it uses index.php as the error document. However, I'd like to suspend this behavior for a specific URL. How can I do this? RewriteCond %{REQUEST_FILENAME} !=fail RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} !=/favicon.ico RewriteRule ^(.*)$ index.php?q=$1 [L,QSA] Where "fail" is the path I want to block. So www.example.com/fail should result in a 404. Incidentally, what does [L, QSA] do? I've looked at documentation without luck.

    Read the article

  • PHP classes, parse syntax errors when using 'var' to declare variables

    - by jon
    I am a C# guy trying to translate some of my OOP understanding over to php. I'm trying to make my first class object, and are hitting a few hitches. Here is the beginning of the class: <?php require("Database/UserDB.php"); class User { private var $uid; private var $username; private var $password; private var $realname; private var $email; private var $address; private var $phone; private var $projectArray; public function _construct($username) { $userArray = UserDB::GetUserArray($username); $uid = $userArray['uid']; $username = $userArray['username']; $realname = $userArray['realname']; $email = $userArray['email']; $phone = $userArray['phone']; $i = 1; $projectArray = UserDB::GetUserProjects($this->GetID()); while($projectArray[$i] != null) { $projectArray[$i] = new Project($projectArray[$i]); } UserDB.php is where I have all my static functions interacting with the Database for this User Class. I am getting errors using when I use var, and I'm getting confused. I know I don't HAVE to use var, or declare the variables at all, but I feel it is a better practice to do so. the error is "unexpected T_VAR, expecting T_VARIABLE" When I simply remove var from the declarations it works. Why is this?

    Read the article

  • mysql syntax how to add a third table to $query

    - by IberoMedia
    I have code: $query = "SELECT a.*, c.name as categoryname, c.id as categoryid". " FROM #__table_one as a". " LEFT JOIN #__table_two c ON c.id = a.catid"; $query .= " WHERE a.published = 1" ." AND a.access <= {$aid}" ." AND a.trash = 0" ." AND c.published = 1" ." AND c.access <= {$aid}" ." AND c.trash = 0" ; I would like to add a third table ('__some_table') for the parts of the query where a.publish, a.access and a.trash. In other words, I want these fields to be retrieved from another table, not "#__table_one", but I do not know how to incorporate the #__some_table into the current query I imagine the JOIN command can help me, but I do not know how to code mysql Thank you,

    Read the article

  • MATLAB syntax of (:)

    - by user198729
    >> I=[2 1 3;3 2 4] I = 2 1 3 3 2 4 >> I(:) ans = 2 3 1 2 3 4 >> I(1:2) ans = 2 3 >> Why the first call I(:) returns a vector while the second I(1:2) doesn't which is essentially the same as I(:)?

    Read the article

  • What's wrong with this Perl 'grep' syntax?

    - by wes
    I've got a data structure that is a hash that contains an array of hashes. I'd like to reach in there and pull out the first hash that matches a value I'm looking for. I tried this: my $result = shift grep {$_->{name} eq 'foo'} @{$hash_ref->{list}}; But that gives me this error: Type of arg 1 to shift must be array (not grep iterator). I've re-read the perldoc for grep and I think what I'm doing makes sense. grep returns a list, right? Is it in the wrong context? I'll use a temporary variable for now, but I'd like to figure out why this doesn't work.

    Read the article

  • Google App Engine: Difficulty with Users API (or maybe just a Python syntax problem)

    - by Rosarch
    I have a simple GAE app that includes a login/logout link. This app is running on the dev server at the moment. The base page handler gets the current user, and creates a login/logout url appropriately. It then puts this information into a _template_data dictionary, for convenience of subclasses. class BasePage(webapp.RequestHandler): _user = users.get_current_user() _login_logout_link = None if _user: _login_logout_link = users.create_logout_url('/') else: _login_logout_link = users.create_login_url('/') _template_data = {} _template_data['login_logout_link'] = _login_logout_link _template_data['user'] = _user def render(self, templateName, templateData): path = os.path.join(os.path.dirname(__file__), 'Static/Templates/%s.html' % templateName) self.response.out.write(template.render(path, templateData)) Here is one such subclass: class MainPage(BasePage): def get(self): self.render('start', self._template_data) The login/logout link is displayed fine, and going to the correct devserver login/logout page. However, it seems to have no effect - the server still seems to think the user is logged out. What am I doing wrong here?

    Read the article

  • Makefile: couple syntax questions

    - by Michael
    package_version := $(version)x0d$(date) what is the x0d part between version and date vars? is it just string? What $(dotin_files:.in=) does below code dotin_files := $(shell find . -type f -name \*.in) dotin_files := $(dotin_files:.in=) what this means $(dotin_files:=.in) code $(dotin_files): $(dotin_files:=.in) $(substitute) [email protected] > $@ can target contain multiple files? what is the meaning of declaring target variable as PHONY? code .PHONY: $(dotin_files) In the regex replacement code below code substitute := perl -p -e 's/@([^@]+)@/defined $$ENV{$$1} ? $$ENV{$$1} : $$&/ge' what are $$ENV{$$1} and $$&? I guess it's Perl scope... thanks for your time

    Read the article

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