Inside a function, I've got:
var myType;
if ( $(this).is(".whatever") ){
myType = typeOne;
} else if ( $(this).is(".something") ){
myType = typeTwo;
}
This works fine. However, I want to turn this into a separate function that I can call, since I use it in several different places. The function I write is:
function setMyType(){
...
I'm not asking about Python's scoping rules; I understand generally how scoping works in Python for loops. My question is why the design decisions were made in this way. For example (no pun intended):
for foo in xrange(10):
bar = 2
print(foo, bar)
The above will print (9,2).
This strikes me as weird: 'foo' is really just control...
I'm a php newbie (but long time developer in other languages) and I'm trying some example db connections in "PHP, MySQL, & JavaScript". It shows an example file to include db connection variables (servername, username, password, database, etc.). I have a php file which has a handful of functions I wrote and one of them has a few SQL quer...
if (isset ($_POST['somethingA']))
{
//code for doing something A
}
elseif (isset ($_POST['somethingB']))
{
//code for doing something B
}
I will need to access some data from somethingA code, into somethingB code.
How can I do that in a proper way?
Should I declare a variable outside the conditionals, work inside th...
I use the using statement for SqlConnection. It's is good for performance because forces calling Dispose() that simply releases the connection to the pool sooner.
However, I realized that object created in using cannot be redefined. I cannot do like this:
using (SqlConnection connection = new SqlConnection(connectionString))
{
...
#include <iostream>
using namespace std;
int main() {
int i;
for(i=0; i <= 11; i+=3)
cout << i;
cout << endl << i << endl;
}
output is: 0 3 6 and 9 and then once it exits the loop its 12.
The addresses of i inside the loop and out appear the same
What I need to know is: Is the i inside the for loop the same as the...
I'd like to create something like a very basic chat application. I don't want to use a database, since it'd cause a heavy load on an already strained db. I also don't want to use a flat file, because it have a feeling that it'd become a mess or that it'll have lots of read/writes...
So, I'm wondering if there is a way to have a variable...
$roidInfo = '';
$nomeDominio ='';
if (isset($_GET['infoDominio']))
{
$nomeDominio = filter_input(INPUT_GET, 'nomeDominio', FILTER_SANITIZE_STRING);
$dominioVo->setNome($nomeDominio);
try
{
...
$roidInfo = isset($infoDominio['roid']) ? $infoDominio['roid'] : '';
}
catch (EppCommandsExcepti...
How come Object.prototype.toString === toString? If I have this in the global scope:
var toStringValue = toString.call("foobaz");
I would expect toStringValue to be the value of window.toString because window is the default scope, right? How come toString by itself resolves to Object.prototype.toString instead of window.toString?
...
As someone who is attempting to take a more object oriented approach to my javascript programming I've hit a stumbling block which I'm sure is probably something very basic, but, take the following object implementation (assume that the jQuery object is available to this code):
function Foo()
{
this.someProperty = 5;
}
Foo.prototyp...
Running the following code:
for (var i=0; i<3; i++) {
setTimeout( function() { console.log(i); } , 500 );
}
Outputs "3" three times. It's outputting the final value of i as opposed to the value of i when the inner function is created.
If I want the output to be 1, 2, and 3, how would I write this code? How can I get it to use th...
I think I understand why there is a danger in allowing closures in a language using dynamic scope. That is, it seems you will be able to close the variable OK, but when trying to read it you will only get the value at the top of global stack. This might be dangerous if other functions use same name in the interim.
Have I missed some o...
Hi Folks,
I'll start with an example snippet:
self.addwidget({
box: ns.box({
text: 'Foobar',
fromTop: ~~(Math.random()*window.innerHeight),
fromLeft: ~~(Math.random()*window.innerWidth),
toTop: 240,
toLeft: ...
I'm trying to get my content page to be able to access an ASP:Literal on a master page.
I have my content page as:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="viewProduct.aspx.cs" Inherits="AlphaPackSite.viewProduct" Title="Hi there!" %>
<%@ MasterType TypeName="Main" %>
Then my master page called Main.master has:
<asp...
How is the scoping of variables handled during exceptions? I suppose this will be language specific, and answers for any specific language are greatly appreciated. At least maybe the big ones? C++, python, Java. This is what I mean:
python
try:
for k, v in map.iteritems():
cnf.conf.set( section, k, ...
I have Servlet that looks something like this:
public class MyServlet extends Servlet {
private class Page {
private Page(HttpServletRequest request, HttpServletResponse response) {
/* Do stuff */
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) {
Page page = new Page(request...
I have the following code:
function p (str)
Response.Write VBLF & str
end function
function nop: end function
class Test1
private sub class_initialize
p "Test1 Start"
end sub
private sub class_terminate
p "Test1 End"
end sub
end class
class Test2
private sub class_initialize
p " Tes...
I'm a Java and C# developer, and, I admit, I'm not that good in PHP.
I need to store an object in an application scope that lives as long as the app itself is running. I can't save it in the Session, because it expires, also I can't serialize it to disk.
Is there something like a C# Application object in PHP?
...
Hi, can anyone tell me how to create a list in one class and access it from another?
...
I have a couple of domain classes defined, Employee and EmployeeDesiredSkill,
Employee has
static hasMany = [employeeSkill:EmployeeDesiredSkill]
and EmployeeDesiredSkill has
static belongsTo = [employee:Employee]
Yet groovyc is giving me a bunch of errors like the following:
[groovyc] Compiling 15 source files to C:\dev\JavaTes...