处理数据结构 [英] Processing a Data Structure

查看:71
本文介绍了处理数据结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一个关于转换我的数据集中的一些数据但是保留一些数据的问题。


我有一个哈希,如果密钥存在且哈希的值等于B,它应该转换这些数字,但如果B不存在,数据应该保持不变。


my输出是所有数据都转换而不仅仅是B存在的情况。


这是我的脚本

Hi,

I have a question about converting some of the data in my dataset but leave some data the way it is.

I have a hash and if the key is present and the Value of the Hash equals B it should convert these number but if B is not present the data should remain the same.

my output is that all the data is converted not in the only the cases were B is present.

This is the script i have

展开 | 选择 | < span class =codeLinkonclick =WordWrap(this);> Wrap | 行号

推荐答案

做y你有一个数组或哈希?

Do you have an array or a hash?

展开 | 选择 | Wrap | 行号


''B''是一个字符串(很可能)不是数字,所以使用''eq''而不是''=='':

''B'' is a string (most likely) not a number, so use ''eq'' instead of ''=='':

展开 | 选择 | Wrap | 行号


感谢您的帮助。我试过它,就像你说它是一个哈希所以这是我用过但我没有得到任何输出!我希望你能帮我弄清楚我应该做些什么!

Thank you for your help. I tried it like you said it is a hash so this is what i used but im not getting any output! I hope you can help me figure out what i should do!

展开 | 选择 | Wrap | 行号


这篇关于处理数据结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆