I am getting data in below eg format and I want to use split function on 'testabc1223./67767' but I can't use it as it is an object and split cannot be used on object please let me know how can I use split on this
{
name: 'testabc1223./67767'
}
You shuld get the object property like that:
YOUR_OBJECT.name.split(...);
Related
I have created an empty lists using
var lift = mutableListOf<Any(mutableListOf<Any(),mutableListOf<Any>())
But
lift[0].add(1)
Gives me error.
How to add elements to list inside list
The problem is that you have upcast the list type to Any instead of MutableList<Any>.
If you just typed:
mutableListOf(mutableListOf<Any>(),mutableListOf<Any>())
the type of items in the list is implicitly MutableList<Any>. But since you added <Any> like this:
mutableListOf<Any>(mutableListOf<Any>(),mutableListOf<Any>())
the compiler treats retrieved items as type Any instead of the specific type MutableList<Any> so you can't call functions on them.
You could also explicitly state the type like this, but it is not necessary:
mutableListOf<MutableList<Any>>(mutableListOf<Any>(),mutableListOf<Any>())
Try this:
val lift: MutableList<MutableList<Any>> = mutableListOf<MutableList<Any>>(mutableListOf<Any>(),mutableListOf<Any>())
I'm trying to get some data from a JSON file, but I can't use require because I need the path to be a variable and if I try to use require with a variable I get an error:
invalid call
Here is the function :
async fetchData(dataPath){
require(dataPath);
return data;
}
The dataPath variable is dependent on a selected button.
Hey since its static data could you simply make an object of all possibilities
const allPossibleData = {
customData1: require('./pathToData1'),
customData2: require('./pathToData2')
}
and simply get data by allPossibleData['customData1'], since dynamic require with a variable is not possible otherwise, you can simply do it like this
fetchData(require('dataPath'))
and on function instead getting dataPath as rgument simply get data.
I am a beginner in Vue. I need to create template as follows:
<h3>{{message[{{language}}]}}</h3>
or
<h3>{{message.{{language}}}}</h3>
where message is an object and language is a string variable containing selected language (e.g. "en").
Above mentioned code does not work (error compiling template). Is there any solution for this?
EDIT – Example:
Let us say we have the object: message = {en: "Welcome"} and the string variable language = "en".
Then I want to print <h3>Welcome</h3>.
You can use template literal:
<h3>{{`message[{{language}}]`}}</h3>
The preceding example will print:
message[{{language}}]
And if the message is variable, use ${variable_name}:
<h3>{{`${message}[{{language}}]`}}</h3>
Are you trying to use like?
<h3>{{message[language]}}</h3>
I'm trying to make a lookup to a hash table m.notes using concatenated value of position.qid and literal ".qid" like this:
$tag(name="itemId", content=m.notes.(position.qid".qid").itemId)$
I tried different options, but I get runtime error. Can someone correct my syntax?
Put the 2 items in an array. StringTemplate concatenates all items in an array (or as they call it, a multi-valued-attribute) when it executes a ToString() on it.
[position.qid, ".qid"]
So, if position.qid evaluates to "hello", this expression would become
hello.qid.
Not sure whether such concatenation is possible in string template. Why don't you use a different method that could do the concatenation and return the value.
e.g:
position.fullQid instead of position.qid
where,
public String getFullQid(){
return getQid() + ".qid";
}
in template group, I can do like this, first, define a concantenate template:
concantenate(substr)::=""
then use as following
(concantenate([position.qid,".qid"]))
Is there a way to dynamically compute the input value to a LOAD statement in pig? Conceptually, I want to do something like this:
%declare MYINPUT com.foo.myMethod('2013-04-15');
raw = LOAD '$MYINPUT' ...
myMethod() is a UDF that accepts a date as input and returns a (comma-separated) list of directories as a string. That string is then given as the input to the LOAD statement.
Thanks.
It doesn't sound to me like myMethod() needs to be a UDF. Presuming this list of directories doesn't need to be computed in map reduce you could run the function to get the string first, then make it a property you pass to pig. Sample if your driver was in java provided below:
String myInput = myMethod("2013-04-15");
PigServer pig = new PigServer(ExecType.MAPREDUCE);
Map<String,String> myProperties = new HashMap<String,String>();
myProperties.put("myInput",myInput);
pig.registerScript("myScriptLocation.pig");
and then your script would start with
raw = LOAD '$myInput' USING...
this is assuming your myInput String is in a glob format PigStorage can read, or you have a different LoadFunc that can handle your comma separated string in mind.
I had a similar issue and opted for a Java LoadFunc implementation instead of a pre-processor. Using a custom LoadFunc means the script can still be run by analysts using the stock pig executable, and doesn't require another dependency.