scope

Difference from `{.}/*:name` and `*/*:name` in sbt?

谁都会走 提交于 2020-01-23 06:24:13
问题 From some sbt document(e.g. scopes), I see: {.}/*:name means name in entire build (use name in ThisBuild to define it) */*:name means name in global project (use name in Global to define it) (PS: I ignored the config part *: ) But, I still don't know what is the difference between them, they seem exactly the same to me. Is there any thing I can do with one rather than another one? 回答1: Whatever version you specified in ThisBuild will be applied to all projects in your build, overriding

PHP: friend classes and ungreedy caller function/class

喜夏-厌秋 提交于 2020-01-22 16:27:31
问题 Is there any way to get the caller function with something else than debug_backtrace()? I'm looking for a less greedy way to simulate scopes like friend or internal . Let's say I have a class A and a class B. Until now, I've been using debug_backtrace() , which is too greedy (IMHO). I thought of something like this: <?php class A { public function __construct(B $callerObj) {} } class B { public function someMethod() { $obj = new A($this); } } ?> It might be OK if you want to limit it to one

PHP variable scope within Try/Catch block

最后都变了- 提交于 2020-01-22 13:53:25
问题 In PHP, how do variable scope rules apply to Try/Catch blocks? Do variables declared within the try block go out of scope when the block has finished? Or are they in scope until the end of the function/method? For example: try { // This may throw an exception when created! $o = new Pronk(); } catch (Exception $ex) { // Handle & exit somehow; not important here return false; } $o->doPronk(); Is this valid? Or should $o = NULL; be set before the try/catch to keep $o in scope? (I know that the

Beginner Java: Variable Scope Issue

纵然是瞬间 提交于 2020-01-22 03:48:09
问题 I'm practicing some work from my java book and I'm having an issue with getting a method to use a variable for a calculation. Please note that this is a work in progress and I'm only trying to get it to use the circleArea method to calculate the area of a circle at the moment. Here is the necessary code: public class Geometry { public static void printMenu() { System.out.println("This is a geometry calculator\nChoose what you would like to calculate" + "\n1. Find the area of a circle\n2. Find

closure in for-loop > different tries failed

烈酒焚心 提交于 2020-01-22 03:42:09
问题 I want to create a 2-dimensional array with an index-number in each first element. EDIT: thx a lot so far.. @carl: I did so much function creation just to show the kind of tries I did.. jonhopkins idea gave rise to this: this works: $('#create_indexed_array').click(function() { var new_array = [[9,9],[9,9],[9,9],[9,9],[9,9]]; for (var i = 0; i < 5; i++) { new_array[i][0] = i; } alert(JSON.stringify(new_array)); }); BUT this works not: $('#create_indexed_array').click(function() { var new

JAVA, SWT Local variable i defined in an enclosing scope must be final or effectively final

余生颓废 提交于 2020-01-22 03:34:05
问题 I'm trying to create an i*j number of buttons. On each button I want to add an mouseUp action, but I get an error. I tried to create a "Line" class to handle the listener event but failed. This is what I currently have: protected void createContents() { // Connect to prolog engine Query.hasSolution("use_module(library(jpl))"); // only because we call e.g. jpl_pl_syntax/1 below String t1 = "consult('dots_lines.pl')"; Query.hasSolution(t1); // Build GUI shell = new Shell(); shell.setSize(450,

Can I set this.'something' of a service within a nested object that is dynamically created in that service? (maybe scope issues)

冷暖自知 提交于 2020-01-22 02:54:07
问题 I have the following service (it actually has more levels and elements but I trimmed it down to just a single example of what I'd like to work). It creates javascript objects within other objects dynamically based on csv files in the app.data folder. The line most relevant to this question is this.images = images; after the inner-most for loop. app.service('tabInfoService',function(csvService, tabsService ){ var tabData = tabsService.tabData; var tabCount = tabsService.tabCount; this.tabs={};

Why does C allow me to call an undeclared function? [duplicate]

浪尽此生 提交于 2020-01-21 12:53:09
问题 This question already has answers here : Why the error of - calling the function before being declared, is not shown? (3 answers) Closed 2 years ago . I have two files: test1.c , and test2.c , which contains the main() function. test1.c: #include <stdio.h> // printf() function declaration/prototype // function definition void say_hello() { printf("\tHello, world!\n"); } test2.c: #include <stdio.h> // printf() function declaration/prototype int main() { printf("Inside main()\n"); say_hello();

Is it possible to bind a global variable in ng-model?

女生的网名这么多〃 提交于 2020-01-17 07:27:52
问题 new to angularJS, after reading the Reference about Scope If all controllers share a $rootScope in a ng-app , can we share a ng-model which is assigned to the $rootScope , so that controllers could communicate with each other? Test with the following snippet, but gName failed to change when model in inputController changed, presume may be gName was made $scope.gName again when input changed. if that is true, is there any way to communicate the controller with each other? ie, the input could

how to avoid name conflicts coming from #define in C? (or C++)

ⅰ亾dé卋堺 提交于 2020-01-17 06:04:40
问题 This should be very basic question, and I can avoid this situation by changing some names but I think maybe there is something I am missing here. I have made a simplest code for this problem. conv.h : 1 struct convpar_ { 2 int K; 3 } convpar_; test.c : 1 #include <stdio.h> 2 #include "conv.h" 3 4 #define K 7 5 6 typedef struct convpar_ convpar; 7 8 void func1(convpar cp) 9 { 10 printf("cp.K = %d\n", cp.K); 11 } 12 13 main() 14 { 15 convpar cp = {K}; 16 17 func1(cp); 18 } If I do cc test.c -o