我的目标是让用户输入屏幕分辨率并将其存储在screen_size
中。我做到了,但是有一个错误。
class Screen
attr_accessor :screen_size, :info
def initialize(screen_size, info)
@screen_size = screen_size
@info = info
end
end
my_info = Screen.new("What is you're resolution?")
my_screen = Screen.new(gets.chomp)
# >> in `initialize': wrong number of arguments (given 1, expected 2) (ArgumentError)
我该如何解决?
答案 0 :(得分:2)
您将错误的参数传递给Screen.new
。您的initialize
方法需要两个参数,而您只传递了一个。
尝试一下:
screen = Screen.new(gets.chomp, "What is you're resolution?")
答案 1 :(得分:1)
import React, { Component } from 'react';
import Video fom 'react-native-video';
export default class VideoTest extends React.Component {
render() {
return (
<View>
<Video
source={{ uri: "https://s3.amazonaws.com/yojma/hls/movie/TDGVYNnBhbQMusqagzXlUZmKxcJPEoSdvIpwLAef/main.m3u8"}}
/>
</View>
)
}}
返回一个值(这是您在按Enter键之前输入的值)。该方法需要两个。如果输入的是“ 1024 768”之类的内容,则可以按空格分隔输入内容。像这样:
gets.chomp