#numbers are classified as certificate integer, floating-point number float (corresponding to double in other languages), and plural complex#integers are divided into fixnum and Bignum,fixnum and Bignum to each other, and these are the operations that Ruby automatically manages. a=123_333_3432#Adding an underscore does not affect the value of a numberputs Aputs 0b00000010#0b is a binaryPuts 0123#0 is octalPuts 0xa0#hexadecimalPuts 2<=>2#the former larger than the latter returns 1, equals returns 0, smaller than the latter returns-1#floating point float#String strings usually use single or double quotation marksStr='1233DD'Str="1233ff"#Sometimes you need to construct a very long and contain a lot of single quotes, double quotes, so it is more cumbersome#Ruby also provides string notation such as%,%q and%q, which need to be followed by a bunch of delimiters to contain strings (<>,{},[] and so on), here for large segments of text using << start, plus start and end identities str=%{"FDSF '"Dsf"}str=%q{"FDSF '"Dsf"}str=%q{"FDSF '"Dsf"}str=<<H Sdfsdfsdgasgsaldfjsaldfkjas;dlfkja;sdlkfjlsdfsadfsadfsdfasdfah#An embedded string is a method that checks a string form of a variable into another string using the format # (VAL), and if Val is not a string type, the To_s method of Val is called before the implicit conversion, and then the inlineName="Ma Huan"puts"my name is #{name}"#<< the same effect as the + operation. Attaches the given object to the string object, generating a new object. str<<"the new haha"puts Str.include? ("haha")#symbol type, a string of the same content may be two different objects, and the symbol represented by the same identifier refers to the same instance from anywhere, pointing to the same reference. #symbols are compared with strings and consume less memory. A="Str"b="Str"puts a.object_id==B.OBJECT_IDSA=: STRSB=: strputs sa.object_id==sb.object_id
Ruby Basic data types