I am trying to define a function which can access variables which are in the scope of the function that is calling it.
( I am attempting to build a string formatter that is prettier than "a" + b, and more terse than String.format("a{0}",b). So I can get SF("a{b}"), and I don't know if it is possible )
so
function magic(str) {
re...
I'm just curious...
Is it possible to release a variable in c#?
What I mean is, can you do something like this:
...
string x = "billy bob";
//release variable x somehow
string x = "some other string";
//release variable x somehow
int x = 329;
...
... so basically you are declaring the variable multiple times in the same scope.
...
Here's some code from Richard Jones' Blog:
with gui.vertical:
text = gui.label('hello!')
items = gui.selection(['one', 'two', 'three'])
with gui.button('click me!'):
def on_click():
text.value = items.value
text.foreground = red
My question is: how the heck did he do this? How can the conte...
Where do you store application scoped components in your winforms apps? I see that I can create a descendant of Component in my application. I could then drag and drop the components that I want to share among the forms in my project. Is this the best practice for shared access to components (non-visual controls)? In Delphi, we had a Dat...
I want to achieve this (import functions from util table as local values):
function blah ()
local x = util.x
local y = util.y
...
end
without having to reference each function explicitly, e.g. something like:
function blah()
for name,f in util do
???
end
end
Unfortunately there is no local table that I could set the wa...
I am trying to create a sort of generic xml parser, like this:
Part 1:
An object with filter is created:
var product = {
holder : {
id: '',
title: '',
text : '',
price: ''
},
filter : {
id: '',
test: function( elementHolder ) {
if( elementHolder.id == product.filter.id ) {
return true;
...
I'm very new to AIR development, and have just started seriously building my first simply application. I'd like to open a new window to prompt the user for desired settings upon first run. In testing the new window and detecting its closed state, I've done the following (some jQuery code included):
The following code is used to open t...
Let's say I have the following code:
public class Foo
{
private int x;
private int y;
public Bar CreateBar()
{
return new Bar(x, () => y);
}
}
[Serializable]
public class Bar
{
private int a;
private Func<int> b;
public Bar(int a, Func<int> b)
{
this.a = a;
this.b = b;
}...
I don't understand the following:
var x = function() {
this.foo="foo";
return function() {
this.bar = "bar";
return foo+bar;
};
}(); // returns inner
alert(x()); // 'foobar', so both 'this' variables are set
alert(x.bar); // undefined - but wasn't it used correctly?
alert(new x().bar); // ok, works
My assumption was that a def...
I am struck in a small recursive code. I have printed output and it prints fine but when I try to put a counter to actually count my answers, it gives me scooping errors.
total = 0
def foo(me, t):
if t<0:
return
if t==0:
total = total+1
return
for i in range(1, me+1):
total = total+1
return foo(i, t-...
Sorry this is kinda long, but I needed to get the right scenario.
This outputs all C's, why??
thanks in advance
import java.util.Hashtable;
public class Main {
public static ContainsTheHash containsthehash = new ContainsTheHash();
public static StoresValues storesvalues = new StoresValues();
public static GetsValuesAn...
It seems as though different instances of a class can know about each others' private member variables.
I have provided some code that attempts to showcase my issue, and I will try to explain it.
We have a class with a private member variable, $hidden. modifyPrivateMember sets the value of $hidden to 3. accessPrivateMember takes an Obj...
I'd like to scope-limit the effect of I/O stream formatting in C++, so that I can do something like this:
std::cout << std::hex << ...
if (some_condition) {
scoped_iofmt localized(std::cout);
std::cout << std::oct << ...
}
// outside the block, we're now back to hex
so that base, precision, fill, etc. are restored to their previo...
I would like to make a delegate available to an entire class. The point of this is to allow a called method from an external class' backgroundWorker to continually report back through all of it's methods (ExternalClass.Run(); calls ExternalClass.Method2(); ExternalClass.Method3(); etc and they all need to send several progress reports. I...
Imagine some code something like this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<HEAD>
<TITLE>BLAH</TITLE>
<script language='Javascript' type='text/javascript'>
var ScriptVersionReqd='1.0';
</script>
<script language='JavaScript' type='text/jav...
So I have a Perl class. It has a sort() method, and I want it to be more or less identical to the built-in sort() function:
$object->sort(sub ($$) { $_[0] <=> $_[1] });
But I can't do:
$object->sort(sub { $a <=> $b });
Because of scoping. But the List::Util module does this with reduce(). I looked at the List::Util module, and they...
I have a class that creates an anchor object. When the user clicks on the anchor I want it to run a function from the parent class.
function n()
{
var make = function()
{
...
var a = document.createElement('a');
a.innerHTML = 'Add';
//this next line does not work, it returns the error:
//"this.add_but...
Racking my brains on this one. I have the code below: the first stages of a JavaScript game. All the objects are well-defined and I'm using jQuery for DOM interaction. The puzzle is created with the following JS code:
var mypuzzle = new puzzle("{solution:'5+6+89',equations:[['5+3=8',23,23],['5+1=6',150,23],['5+3=6',230,23]]}");
Howev...
Here are the problem scripts:
This is from the HTML file:
<script type="text/javascript">
var devices_record = "some string";
</script>
<script type="text/javascript" src="/js/foo.js"></script>
This is from foo.js:
function bar () {
devices_record = "assign new string";
}
The error report by HttpFox is that devices_ record...
One thing I have noticed a lot of back and forth on is where using statements should be placed in a C# code file- whether its in the outermost scope or inside a namespace. I understand that the location of the using statement affects the scope of the references within that file, but what I don't understand is why, in most cases, someone ...