You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@dubbo.apache.org by GitBox <gi...@apache.org> on 2018/04/19 02:44:56 UTC

[GitHub] myfly150 opened a new issue #1631: Problem when trying script routing rules example in Chapter 6.33 of Dubbo user manual

myfly150 opened a new issue #1631: Problem when trying script routing rules example in Chapter 6.33 of Dubbo user manual 
URL: https://github.com/apache/incubator-dubbo/issues/1631
 
 
   When I tried the  script routing rules example ,  the return value of the example script was always the value of "invokers".
   The example script is as follow:
   ```
   function route(invokers) {
       var result = new java.util.ArrayList(invokers.size());
       for (i = 0; i < invokers.size(); i ++) {
           if ("10.20.153.10".equals(invokers.get(i).getUrl().getHost())) {
               result.add(invokers.get(i));
           }
       }
       return result;
   } (invokers); // Indicates that the method is executed immediately
   ```
   According to the grammar of javascript, the meaning of the example script is :
   ```
   function route(invokers) { ... } ;
   
   (invokers)  // This is a single expression .The return value is always invokers.
   ```
   
   instead of 
   ```
   function route(invokers) { ... } ;
   route(invokers)
   ```
   Actually, brackets surrounding the codeblock is simple solution.
   ```
   (function route(invokers) { ... } (invokers) )
   ```
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services