In both Java and C# it is possible to invoke a private method via reflection (as shown below).
Why is this allowed?
What are the ramifications of doing this?
Should it be taken away in a future version of the language?
Do other languages/platforms allow this?If I have this class in both Java and C#
Here is the example
public cla...
Does a C++ namespace alias defined inside a function definition have a block, function, file, or other scope (duration of validity)?
...
I have a Rails model that should only allow saving/updating of a model once per day per user. I have a callback to do the Find by user and date then add to errors but this is ugly and feels un-rails-like. I have the typical created_at / updated_at columns (and the time portion is significant/I need to keep it).
So I figure I could eithe...
I feel like this must have been asked, but I'm unable to find it through my searches.
Here's a complete example of the issue that's confusing me:
<html><head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript">
(function($){
$.fn.test...
This may have been asked before but I have no idea how to word it to search for it.
I have a composite widget that has methods to update some of the widgets that make up the composite widget. When I add this composite widget to my panel I use a do while loop to pull data from an XML file and populate the composite data. When I instantia...
Hello,
I am extending dojo's dojox.data.JsonRestStore and I want to provide my own fixed scheme.
this is getUsername won't work because it doesn't refer to the current datastore
Take a look at this code:
/**
* @author user
*/
dojo.provide("cms.user.UserAuthenticationStore");
dojo.require("dojox.data.JsonRestStore");
dojo.declare("c...
Hi,
I currently have two classes, one called Dog, one called Poodle. Now how can I use a variable defined in Dog from the Poodle class. My code is as follows:
class dog {
protected static $name = '';
function __construct($name) {
$this->name = $name
}
}
class Poodle extends dog {
functi...
I have a question relating to Perl and scoping. I have a common file with lots of various variables. I require the common file in my main script, but I cannot access the variables; they seem to be outside of its scope. I assumed that an our declaration would overcome that problem, but it doesn't seem to work.
Script 1: common.pl
#!/usr...
Let's say I get an anonymous function an need to act on its context, but it's different whether it's binded to "window" or an unknown object.
How do I get a reference to the object an anonymous function is called from?
EDIT, some code :
var ObjectFromOtherLibIAmNotSupposedToknowAbout = {
foo : function() {
// do something ...
If I have:
Object._extends = function(Derived, Base)
{
Derived.prototype = new Base();
Derived.prototype.constructor = Derived;
Derived.uber = Derived.prototype;
}
var BASE = function()
{
this._name = "BASE"
}
var DERIVED = function()
{
Object._extends(DERIVED, BASE)
this._age = 3;
}
// Object._extends(DERIVED, B...
I am having trouble getting this to work.
I have variables initiated in main which I want to pass onto other functions and have changed. I know the only way this can be done is with pointers or to declare the variables outside the main function.
I would prefer to use pointers
How is it done?
eg
int main(){
int variable1 = 5;
...
Can I do this ?
var global = 0;
var truc = $.getJSON("events.json", function(json){
//alert("JSON Data: " + json[0].titre);
global = json;
});
I want to keep the contents of json and work with it outside the function.
If it was C, I would just keep the pointer but I don't know what to do with JS
...
I have a superclass and a subclass, both of which define instance variables.
Rough outline of superclass:
/* GenericClass.h */
@interface GenericClass : NSObject {
/* some variables */
}
@end
/* GenericClass.m */
@implementation GenericClass
/* ... */
@end
Outline of subclass:
/* SpecificClass.h */
#import "GenericClass.h"
...
I am having issue with the following:
I can't seem to keep the link I am selecting in each repeated item.
The word "this" is getting lost.
the Var event_id works for each element, but the var $something is undefined?
Why is that, Ideally I wanted to do a switch statement but same issue, can't seem to get it to know what link I click an...
I have this ajax call to a doop.php.
function doop(){
var old = $(this).siblings('.old').html();
var new = $(this).siblings('.new').val();
$.ajax({
url: 'doop.php',
type: 'POST',
data: 'before=' + old + '&after=' + new,
success: function(resp) {
if(resp == 1) {
$(this).siblings('.old').html(new);
}
}...
Just wondering, if I statically create an object that has a pointer as a data member and then the object goes out of scope, what happens to the pointer?
Chuma
...
When I compile the following code with g++, the object of class A seems not to be destructed when the object of class C is constructed, and the B.ref_a reference is not broken when accessed by the constructor of object of class C:
#include <iostream>
struct A
{
A(int aa)
{
a = aa;
}
~A()
{
std::cout << "A...
OK, so I'm trying to use S4 classes to build a very complex object, with slots including a half-dozen matrices, a few lists, and probably a kitchen sink or two in there. The object is initialized by referring to and unpacking a configuration object which I've already defined. It's easy enough to define the class with setClass(), but I'm ...
I'm trying to transform certain parts of an XML file to another XML file. The source file:
<CUSTOMERS>
<CUSTOMER>
<CUSTOMER_NUMBER>12345678</CUSTOMER_NUMBER>
<CUSTOMER_ADDRESS>
<CUSTOMER_ADDRESS_NAME>John Doe</CUSTOMER_ADDRESS_NAME>
<CUSTOMER_ADDRESS_STREET>Street 1</CUSTOMER_ADDRESS_STREET>
<CUSTOMER_ADDRESS...
The background to this problem is quite complex and convoluted, and as I am looking for a simple answer, I will leave it by the wayside in explaining my problem, and instead provide this hypothetical situation.
If I have a simple ActiveRecord model called Automobile, with named_scopes like below:
named_scope :classic, :conditions => { ...